2019-11-22 19:34:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Lib;
|
|
|
|
|
2019-11-22 19:42:04 +00:00
|
|
|
/*
|
|
|
|
php.ini
|
|
|
|
|
|
|
|
precision = 16
|
|
|
|
bcmath.scale = 6
|
|
|
|
*/
|
2019-11-22 19:34:10 +00:00
|
|
|
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');
|
|
|
|
}
|