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

评论 (写第一个评论)