Created
April 4, 2020 10:58
-
-
Save lilumi/cfb39e95fb8082b61b76eb9949aeab14 to your computer and use it in GitHub Desktop.
measure php code
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 | |
$start = microtime(true); | |
$cycles = 0; | |
$elapsed = 0; | |
do { | |
$loops = 1000; | |
$begin = microtime(true); | |
do { | |
// Тестируемая операция | |
$arr = range(0,5); | |
shuffle($arr); | |
} while (--$loops); | |
$cycles += 1000; | |
$elapsed += microtime(true) - $begin; | |
} while (microtime(true) - $start < 1); | |
printf("%s: %.0f cycle/sec, %s bytes, %s bytes/cycle\n", PHP_VERSION, $cycles / $elapsed, strlen($result), strlen($result) / $cycles); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment