*** Backup Mirror *** The web interface and JSON api for the ConnectedHumber Air Quality Monitoring Project. https://github.com/ConnectedHumber/Air-Quality-Web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Air-Quality-Web/logic/PerfFormatter.php

27 lines
670 B

<?php
namespace AirQuality;
/**
* Formats performance data to be sent in a HTTP header.
*/
class PerfFormatter {
function __construct() {
}
public static function format_perf_data($start_init, $start_handle, $start_encode) {
$now = microtime(true);
$time_total = round($now - $start_init, 2);
$time_setup = round($start_handle - $start_init, 2);
$time_handle = round(($start_encode ?? $now) - $start_handle, 2);
$time_encode = round($now - $start_encode, 2);
$result = "{$time_total}ms total | {$time_setup}ms setup, {$time_handle}ms handle";
if(!empty($start_encode))
$result .= ", {$time_encode}ms encode";
return $result;
}
}