generated from leonetienne/LaTeX-Paper-template
feat: began writing on wine registration
This commit is contained in:
45
test.php
Normal file
45
test.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
// example code
|
||||
|
||||
function T($arr, $p) {
|
||||
foreach ($arr as $a) {
|
||||
if ($a['parent'] === $p) {
|
||||
T($arr, $a['uid']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testOne($numItems) {
|
||||
$arr = [];
|
||||
for ($i = 0; $i < $numItems; $i++) {
|
||||
$arr[] = [
|
||||
'uid' => $i+1,
|
||||
'parent' => rand(0, $i)
|
||||
];
|
||||
}
|
||||
|
||||
$before = hrtime()[1];
|
||||
T($arr, 0);
|
||||
$after = hrtime()[1];
|
||||
|
||||
$delta = $after - $before;
|
||||
|
||||
return $delta;
|
||||
}
|
||||
|
||||
function testAvg($numItems, $numRuns) {
|
||||
$execTimes = [];
|
||||
for ($i = 0; $i < $numRuns; $i++) {
|
||||
$execTimes[] = testOne($numItems);
|
||||
}
|
||||
|
||||
sort($execTimes);
|
||||
$med = round($execTimes[count($execTimes)/2] / 4206040);
|
||||
|
||||
#echo("$numItems took on average $med time units. ($numRuns sample size)\n");
|
||||
echo("($numItems, $med)\n");
|
||||
}
|
||||
|
||||
for ($i = 0; $i <= 5000; $i += 100) {
|
||||
testAvg($i, 10);
|
||||
}
|
Reference in New Issue
Block a user