Last active
August 29, 2015 14:08
-
-
Save tai-sho/b5e77e9a0f0ef9f05d46 to your computer and use it in GitHub Desktop.
速度計測用関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function bench() { | |
//計測回数 | |
$count = 10; | |
//試行回数 | |
$testCount = 100000; | |
//小数点桁数 | |
$decimalDigits = 10; | |
//平均値 | |
$average = 0.0; | |
for($i = 0; $i < $count; $i++) { | |
$start = microtime(true); | |
for($j = 0; $j < $testCount; $j++) { | |
/****計測対象****/ | |
} | |
$end = microtime(true); | |
$result = $end - $start; | |
echo number_format($result,$decimalDigits)."秒<br>"; | |
$average += $result; | |
} | |
//平均値の出力 | |
$average = number_format($average/$count, $decimalDigits); | |
echo "avarage:$average秒<br>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment