<?php

namespace Lib;

/*
php.ini

precision = 16
bcmath.scale = 6
*/
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');
}