PHPでソースコード実行スピードをテストするサンプル

PHPコード:
<?php

$data = file_get_contents('codespeed.txt’);
$fsize = filesize(“codespeed.txt")/1024;

$start = gettime();

echo $data;

$end = gettime();

$cs = ($end['0’]+$end['1’]) – ($start['0’]+$start['1’]);

$speed = round(($fsize / $cs),2);

echo “<br>スピード: “.$speed." KB/sec.";

function gettime()
{
return explode(" “,microtime());
}

PHP

Posted by arkgame