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

评论 (写第一个评论)