Created
February 4, 2019 15:36
-
-
Save g105b/2ad980429a34e7965e4f1529829af9d8 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 | |
$startTime = microtime(true); | |
$workingDir = "_bm"; | |
$runs = [ | |
100, | |
1000, | |
10000, | |
100000, | |
]; | |
mkdir($workingDir); | |
chdir($workingDir); | |
$value = 0; | |
foreach($runs as $runIndex => $n) { | |
echo "Running test $runIndex ($n)..." . PHP_EOL; | |
for($i = 0; $i < $n; $i++) { | |
file_put_contents(implode("-", [$n, $i]), $i); | |
} | |
echo "Created, checking..." . PHP_EOL; | |
$files = glob("*"); | |
$found = 0; | |
foreach($files as $f) { | |
if(file_exists($f)) { | |
$found ++; | |
unlink($f); | |
} | |
} | |
echo "Found $found files, should be " . count($files) . "." . PHP_EOL; | |
$now = microtime(true); | |
$duration = $now - $startTime; | |
echo "Time: $duration" . PHP_EOL; | |
} | |
chdir(".."); | |
rmdir($workingDir); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment