4.4 测试php函数的查找性能

龸龶龴龰drupal龠龞龜龛龘龖龓龐龠龎龌龈龞龜龛龘龇龄龎龌龃龀齾齼龠齺齷齵齼龈齾齼齺齷齲齯龎龌龓龐

齫齧龞龜龛龘龖齦齣龓龐龠龎龌齟龈龃龀齝齜齛齟齗齖齕

<?php  
$php = "<?php\r\n";  
for ($i = 0; $i < 10000; $i++) {  
    $function_name = "f" . bin2hex(random_bytes(16));  
    $php .= 'function ' . $function_name . '($msg){echo $msg;}' . "\r\n";  
}  
file_put_contents("yunke.php", $php);  
  
include ("yunke.php");  
  
$hooks = [];  
for ($i = 0; $i < 10000; $i++) {  
    $hooks[] = "f" . bin2hex(random_bytes(16));  
}  
$start_time = microtime(TRUE);  
foreach ($hooks as $hook) {  
    if (function_exists($hook)) {  
        echo "$hook exists<br>";  
    }  
}  
$end_time=microtime(TRUE);  
echo "$start_time<br>$end_time<br>time:<br>";  
echo $end_time - $start_time;  

黤黢黟黝齕
黛黙齗黕黑黍黉黈黇龠齾齼龈齺齷齗黕黑黍黉齾齼黇龠黆黂麿麻麸麵2麲麱龈龎龌麮麬齛麮龈麨麤麠麟drupal龠龃龀齺齷麞麸龎龌龓龐

黤黢 黉麛麚麗齕
cpu:麖麓i5-7200U
麊麇:8G
鹾鹼齕win10

评论 (写第一个评论)