PHP code example of eypsilon / mycrobench
1. Go to this page and download the library: Download eypsilon/mycrobench library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eypsilon / mycrobench example snippets
use Many\MycroBench;
/**
* @return array basic usage
*/
MycroBench::get()
// Array
// (
// [start] => 2022-10-10 16:07:00.172129
// [ended] => 2022-10-10 16:07:00.302257
// [took] => 00.130128
// [mem_usage] => 376.21 KB
// [mem_peak] => 16.37 MB
// [
/** Sets the start time for @method getBench() and @method hrBench() to now */
MycroBench::initBench()
/** @param bool true returns additional high resolution times */
MycroBench::getBench(true)
// [start] => 2022-10-10 16:07:00.176997
// [ended] => 2022-10-10 16:07:00.217398
// [took] => 00.040401
// [h_res] => 0.040415356
MycroBench::getBench(true)
// [start] => 2022-10-10 16:07:00.217398
// [ended] => 2022-10-10 16:07:00.239846
// [took] => 00.022448
// [h_res] => 0.022439554
MycroBench::getBench(true)
// [start] => 2022-10-10 16:07:00.239846
// [ended] => 2022-10-10 16:07:00.265409
// [took] => 00.025563
// [h_res] => 0.025560282
// start bench
MycroBench::hrStart()
// do stuff here
// end bench, set first param true to get the result in return
MycroBench::hrEnd(false)
/** @return float|null '0.019044332' */
MycroBench::hrGet()
/** @return float|null '0.019044332' */
MycroBench::hrBench()
/**
* microtimestamp to datetime
*
* @return string '2022-09-01 17:14:48.5000'
*/
(new MycroBench)->getDate('1662045288.5000') # 'U.u', 'Y-m-d H:i:s.u'
/**
* datetime to microtimestamp
*
* @return string '1662045288.5000'
*/
(new MycroBench)->getDateToMicro('2022-09-01 17:14:48.5000') #'Y-m-d H:i:s.u', 'U.u'
/**
* Get microtimestamp for the last request. Only filled
* when @method getBench() has been called
*
* @return string|null '1662623500.7135'
*/
MycroBench::getLastDate()
/**
* Readable bytes
*
* @return string '379.67 KB'
*/
MycroBench::readableBytes(memory_get_usage())
/**
* Default getter
*
* start: $_SERVER['REQUEST_TIME_FLOAT']
* ended: microtime(true)
*
* @static alias MycroBench::get()
*
* @param bool enable (array) get_