index/bench/_init.php

18 lines
371 B
PHP
Raw Normal View History

2022-09-13 13:13:11 +00:00
<?php
require_once __DIR__ . '/../index.php';
function bench(string $name, int $times, callable $body): void {
printf('Running "%s" %d times%s', $name, $times, PHP_EOL);
$sw = \Index\Performance\Stopwatch::startNew();
while(--$times > 0)
$body();
$sw->stop();
printf('Took: %Fms %s', $sw->getElapsedTime(), PHP_EOL);
echo PHP_EOL;
}