{"id":20935531,"url":"https://github.com/eypsilon/mycrobench","last_synced_at":"2026-04-20T20:03:29.977Z","repository":{"id":58851505,"uuid":"534130269","full_name":"eypsilon/MycroBench","owner":"eypsilon","description":"MycroBench | Lightweight time measure tool for PHP","archived":false,"fork":false,"pushed_at":"2023-03-10T11:51:28.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-19T19:58:05.359Z","etag":null,"topics":["measure","microtime","php"],"latest_commit_sha":null,"homepage":"https://mycro-bench.vercel.app/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eypsilon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-09-08T08:58:41.000Z","updated_at":"2023-03-08T21:03:08.000Z","dependencies_parsed_at":"2024-01-12T18:39:03.802Z","dependency_job_id":"e0e2c5b4-5144-458f-9115-c30399eeb4e2","html_url":"https://github.com/eypsilon/MycroBench","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"082666fee9284d2debc9437bb9124edc395fec42"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eypsilon%2FMycroBench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eypsilon%2FMycroBench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eypsilon%2FMycroBench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eypsilon%2FMycroBench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eypsilon","download_url":"https://codeload.github.com/eypsilon/MycroBench/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243330259,"owners_count":20274037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["measure","microtime","php"],"created_at":"2024-11-18T22:15:26.427Z","updated_at":"2025-12-25T20:56:34.066Z","avatar_url":"https://github.com/eypsilon.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MycroBench | Lightweight time measure tool for PHP\n\nThis Package uses `$_SERVER['REQUEST_TIME_FLOAT']` and `microtime()` to calculate the difference that has passed between both times, when instantiated. It also provides a basic implementation of `hrtime()`, which allows measuring processing times with higher precision.\n\nSee [./public/index.php](./public/index.php) for examples or check the livedemo on [Vercel](https://mycro-bench.vercel.app/).\n\n```terminal\ncomposer require eypsilon/MycroBench\n```\n\n```php\nuse Many\\MycroBench;\n\n/**\n * @return array basic usage\n */\nMycroBench::get()\n\n// Array\n// (\n//     [start] =\u003e 2022-10-10 16:07:00.172129\n//     [ended] =\u003e 2022-10-10 16:07:00.302257\n//     [took] =\u003e 00.130128\n//     [mem_usage] =\u003e 376.21 KB\n//     [mem_peak] =\u003e 16.37 MB\n//     [included_files_total] =\u003e 37\n// )\n```\n\n## Consecutive requests\n\nGet the processing time that has passed between consecutive requests with internally staid `start` times.\n\nThe first request will use `$_SERVER['REQUEST_TIME_FLOAT']` as `start` time, subsequent requests will use the `ended` time from previous requests.\n\nSet the initial start time for benches manually to *now*. This is optional, but the first high resolution time will be wrong, if it's not instantiated.\n\n```php\n/** Sets the start time for @method getBench() and @method hrBench() to now */\nMycroBench::initBench()\n```\n\n```php\n/** @param bool true returns additional high resolution times */\nMycroBench::getBench(true)\n\n// [start] =\u003e 2022-10-10 16:07:00.176997\n// [ended] =\u003e 2022-10-10 16:07:00.217398\n// [took] =\u003e 00.040401\n// [h_res] =\u003e 0.040415356\n\nMycroBench::getBench(true)\n\n// [start] =\u003e 2022-10-10 16:07:00.217398\n// [ended] =\u003e 2022-10-10 16:07:00.239846\n// [took] =\u003e 00.022448\n// [h_res] =\u003e 0.022439554\n\nMycroBench::getBench(true)\n\n// [start] =\u003e 2022-10-10 16:07:00.239846\n// [ended] =\u003e 2022-10-10 16:07:00.265409\n// [took] =\u003e 00.025563\n// [h_res] =\u003e 0.025560282\n```\n\n\n## High resolution times\n\nGet `microtimes` with the system's high resolution time using [hrtime()](https://www.php.net/manual/de/function.hrtime.php).\n\nMicrosec: `00.019045`\n\nHigh Reso: `0.019044332`\n\n```php\n// start bench\nMycroBench::hrStart()\n\n// do stuff here\n\n// end bench, set first param true to get the result in return\nMycroBench::hrEnd(false)\n\n/** @return float|null '0.019044332' */\nMycroBench::hrGet()\n```\n\nGet high resolution times with internally staid start times.\n\n```php\n/** @return float|null '0.019044332' */\nMycroBench::hrBench()\n```\n\n\n#### Misc\n\n```php\n/**\n * microtimestamp to datetime\n *\n * @return string '2022-09-01 17:14:48.5000'\n */\n(new MycroBench)-\u003egetDate('1662045288.5000') # 'U.u', 'Y-m-d H:i:s.u'\n\n/**\n * datetime to microtimestamp\n *\n * @return string '1662045288.5000'\n */\n(new MycroBench)-\u003egetDateToMicro('2022-09-01 17:14:48.5000') #'Y-m-d H:i:s.u', 'U.u'\n\n/**\n * Get microtimestamp for the last request. Only filled\n * when @method getBench() has been called\n *\n * @return string|null '1662623500.7135'\n */\nMycroBench::getLastDate()\n\n/**\n * Readable bytes\n *\n * @return string '379.67 KB'\n */\nMycroBench::readableBytes(memory_get_usage())\n\n/**\n * Default getter\n *\n * start: $_SERVER['REQUEST_TIME_FLOAT']\n * ended: microtime(true)\n *\n * @static alias MycroBench::get()\n *\n * @param bool   enable (array) get_included_files()\n * @param string set a needle to shorten the paths returned in get_included_files()\n * @return array\n */\n(new MycroBench)-\u003egetAll(true, '/remove/from/included_files/paths')\n\n/**\n * Consecutive getter\n *\n * @static alias MycroBench::getBench()\n *\n * @param bool get additionally higher resolution times\n * @return array\n */\n(new MycroBench)-\u003egetBenchDiff(true)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feypsilon%2Fmycrobench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feypsilon%2Fmycrobench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feypsilon%2Fmycrobench/lists"}