Skip to content

Instantly share code, notes, and snippets.

@lilumi
Created April 4, 2020 10:58
Show Gist options
  • Save lilumi/cfb39e95fb8082b61b76eb9949aeab14 to your computer and use it in GitHub Desktop.
Save lilumi/cfb39e95fb8082b61b76eb9949aeab14 to your computer and use it in GitHub Desktop.
measure php code
<?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