php(PEAR)の実行速度測定
<?php //準備(手動モード) require_once 'Benchmark/Profiler.php'; $profiler = new Benchmark_Profiler; //全体開始 $profiler->start(); //セクション開始 $profiler->enterSection('i_cnt100'); for($i=0;$i<100;$i++) { $str[]=$i; } $profiler->leaveSection('i_cnt100'); //セクション終了 //セクション開始 $profiler->enterSection('j_cnt150'); for($j=0;$j<150;$j++) { if($j<100) { $str[$j]=null; } } $profiler->leaveSection('j_cnt150'); //セクション終了 //全体停止 $profiler->stop(); //出力 $profiler->display(); ?>
こんな感じ。実行形式はhtmlで返される。
解説すると、
$profiler->enterSection('i_cnt100');
で名称を定義してセクションを始めている
$profiler->leaveSection('i_cnt100');
で定義したセクションを終えている
セクション名称は日本語でもok