Pashok Asked:2020-05-23 15:29:09 +0000 UTC2020-05-23 15:29:09 +0000 UTC 2020-05-23 15:29:09 +0000 UTC 如何找出脚本执行的速度? 772 有一项任务是将 R 语言添加到 php。我想比较一下纯php和R语言的脚本执行速度,这个怎么查,用什么资源? php 1 个回答 Voted Best Answer SnakeMS 2020-05-23T16:05:11Z2020-05-23T16:05:11Z 对于 PHP 第一种方式(最简单)。我使用microtime函数,时间以毫秒为单位显示: $start = microtime(true); my_code(); $time = microtime(true) - $start; echo 'Время выполнения скрипта: '.$time.' мс.'; 第二种方法是使用Xhprof扩展: // start profiling xhprof_enable(); // run program my_code(); // stop profiler $xhprof_data = xhprof_disable(); // display raw xhprof data for the profiler run print_r($xhprof_data);
对于 PHP
第一种方式(最简单)。我使用microtime函数,时间以毫秒为单位显示:
第二种方法是使用Xhprof扩展: