Ss cpu test
0) $iterations=$custom;
}
$result=null;
if($type && $iterations>0 && !$stopFlag){
@set_time_limit(0);
$startWall=microtime(true);
$startCpu=get_cpu_seconds();
if($type==="hash"){ bench_hash($iterations); $label="SHA-256 hashing ($iterations iterations)";}
elseif($type==="prime"){ bench_primes($iterations); $label="Prime numbers ($iterations)";}
elseif($type==="matrix"){ bench_matrix($iterations); $label="Matrix multiplication (~".(int)sqrt($iterations)."x".(int)sqrt($iterations).")";}
$endWall=microtime(true);
$endCpu=get_cpu_seconds();
$wall=$endWall-$startWall;
$cpu=($startCpu!==null && $endCpu!==null)?($endCpu-$startCpu):null;
$result=[
"label"=>$label,
"wall"=>$wall,
"cpu"=>$cpu,
"iter"=>$iterations,
"speed"=>$wall>0?round($iterations/$wall,2):null
];
// Store in cookie
$prev=json_decode($_COOKIE['prevBench']??'[]',true);
array_unshift($prev,$result);
if(count($prev)>10) $prev=array_slice($prev,0,10);
setcookie("prevBench",json_encode($prev),time()+86400*30); // 30 days
}else{
$prev=json_decode($_COOKIE['prevBench']??'[]',true);
}
?>
PHP CPU Benchmark
⚡ PHP CPU Benchmark
Test:
Wall time:
CPU time:
Throughput:
Wall time:
CPU time:
Throughput:
Previous Results:
| # | Test | Iterations | Wall Time | CPU Time | Ops/sec |
|---|---|---|---|---|---|
Shared hosting may limit execution time. Multiple tabs can simulate multi-core load.
Comments
Post a Comment