25 lines
508 B
PHP
25 lines
508 B
PHP
|
<?php
|
||
|
|
||
|
namespace Lib;
|
||
|
|
||
|
function microtime_calc(): array
|
||
|
{
|
||
|
static $last = null; // 1st time
|
||
|
static $sum = 0.0; // 1st time
|
||
|
$mt = microtime(true);
|
||
|
$diff = is_null($last)? 0.0: bcsub($mt, $last);
|
||
|
$sum = bcadd($sum, $diff);
|
||
|
$last = $mt;
|
||
|
return [$sum, $diff];
|
||
|
}
|
||
|
|
||
|
function printf(string $str, ...$args): int
|
||
|
{
|
||
|
return \printf("∑%.6f +%.6f | ". $str."\n", ...microtime_calc(), ...$args);
|
||
|
}
|
||
|
|
||
|
function plain(): void
|
||
|
{
|
||
|
header('Content-Type: text/plain');
|
||
|
}
|