Skip to content

Commit 38dde92

Browse files
authored
trasnlate
1 parent 3d6a190 commit 38dde92

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

test_php_function.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
<?php
22
/**
3-
* Этот маленький скриптик подскажет какие из функций PHP сколько поедают ресурсов и затрачивают времени.
4-
* Он поможет не использовать сверх производительные функции.
5-
* Советую тестировать на локалхосте.
3+
* This small script will tell you which of the PHP functions how much they eat resources and spend time.
4+
 * It will help not to use super productive functions.
5+
 * I advise you to test on localhost.
66
*/
77

88
$total = 5000;
9-
// Генерим массив
9+
// Craft array
1010
$array = array();
1111
for ($j = 0; $j < $total; $j++) {
1212
$array[$j] = 'a' . $j;
1313
}
1414

15-
// Проверяем in_array
15+
// check "in_array"
1616
$s = microtime(true);
1717
for ($j = 0; $j < $total; $j++) {
1818
in_array("a555", $array);
1919
}
2020
echo "in_array: " . (microtime(true) - $s) . "\n";
2121

22-
// Проверяем array_flip
22+
// check "array_flip"
2323
$s = microtime(true);
2424
$array = array_flip($array);
2525
echo "<br />array_flip: " . (microtime(true) - $s) . "\n";
2626

27-
// Проверяем array_key_exists
27+
// check "array_key_exists"
2828
$s = microtime(true);
2929
for ($j = 0; $j < $total; $j++) {
3030
array_key_exists("555", $array);
3131
}
3232
echo "<br />array_key_exists: " . (microtime(true) - $s) . "\n";
3333

34-
// Проверяем isset
34+
// check "isset"
3535
$s = microtime(true);
3636
for ($j = 0; $j < $total; $j++) {
3737
if(isset($array[555])) $c = true;
3838
}
3939
echo "<br />isset: " . (microtime(true) - $s) . "\n";
4040

41-
// Проверяем isset через foreach
41+
// check "isset" with "foreach"
4242
$s = microtime(true);
4343
for ($j = 0; $j < $total; $j++) {
4444
foreach($array AS $k=>$v) {
@@ -48,7 +48,7 @@
4848
}
4949
echo "<br />foreach isset: " . (microtime(true) - $s) . "\n";
5050

51-
// Проверяем Просто foreach
51+
// check "foreach"
5252
$s = microtime(true);
5353
for ($j = 0; $j < $total; $j++) {
5454
foreach($array AS $k=>$v) {

0 commit comments

Comments
 (0)