{"id":18550296,"url":"https://github.com/xp-forge/measure","last_synced_at":"2025-08-12T12:34:18.277Z","repository":{"id":57084820,"uuid":"24306418","full_name":"xp-forge/measure","owner":"xp-forge","description":"Measuring API","archived":false,"fork":false,"pushed_at":"2022-02-27T09:36:24.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-21T11:49:59.768Z","etag":null,"topics":["measure","performance","php","xp-framework"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xp-forge.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-21T22:21:30.000Z","updated_at":"2022-02-27T09:32:03.000Z","dependencies_parsed_at":"2022-08-24T14:59:11.419Z","dependency_job_id":null,"html_url":"https://github.com/xp-forge/measure","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/xp-forge/measure","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmeasure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmeasure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmeasure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmeasure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-forge","download_url":"https://codeload.github.com/xp-forge/measure/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmeasure/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270061499,"owners_count":24520309,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","performance","php","xp-framework"],"created_at":"2024-11-06T21:04:08.273Z","updated_at":"2025-08-12T12:34:18.221Z","avatar_url":"https://github.com/xp-forge.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Measure\n=======\n\n[![Build status on GitHub](https://github.com/xp-forge/measure/workflows/Tests/badge.svg)](https://github.com/xp-forge/measure/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-forge/measure/version.png)](https://packagist.org/packages/xp-forge/measure)\n\nMeasuring performance of different implementations in an xUnit-style way.\n\nExample\n-------\n\n```php\nuse util\\profiling\\{Measure, Measurable};\n\nclass Iteration extends Measurable {\n  \n  #[Measure]\n  public function strpos() {\n    return false === ($p= strpos('abc.', '.')) ? -1 : $p;\n  }\n\n  #[Measure]\n  public function strcspn() {\n    return 4 === ($p= strcspn('abc.', '.')) ? -1 : $p;\n  }\n}\n```\n\nRunning:\n\n```sh\n$ xp measure -1000000 Demo\nstrpos: 1000000 iteration(s), 0.308 seconds, result= 3\nstrcspn: 1000000 iteration(s), 0.350 seconds, result= 3\n```\n\nPermutation\n-----------\n\n```php\nuse util\\profiling\\{Measure, Measurable, Values};\n\nclass Demo extends Measurable {\n\n  #[Measure, Values(['', '.', '.a', 'a.', 'a.b'])]\n  public function strpos($fixture) {\n    return false === ($p= strpos($fixture, '.')) ? -1 : $p;\n  }\n\n  #[Measure, Values(['', '.', '.a', 'a.', 'a.b'])]\n  public function strcspn($fixture) {\n    return strlen($fixture) === ($p= strcspn($fixture, '.')) ? -1 : $p;\n  }\n}\n```\n\nRunning:\n\n```sh\n$ xp measure -1000000 Demo\nstrpos(\"\"): 1000000 iteration(s), 0.534 seconds, result= -1\nstrpos(\".\"): 1000000 iteration(s), 0.527 seconds, result= 0\nstrpos(\".a\"): 1000000 iteration(s), 0.523 seconds, result= 0\nstrpos(\"a.\"): 1000000 iteration(s), 0.531 seconds, result= 1\nstrpos(\"a.b\"): 1000000 iteration(s), 0.541 seconds, result= 1\nstrcspn(\"\"): 1000000 iteration(s), 0.633 seconds, result= -1\nstrcspn(\".\"): 1000000 iteration(s), 0.617 seconds, result= 0\nstrcspn(\".a\"): 1000000 iteration(s), 0.622 seconds, result= 0\nstrcspn(\"a.\"): 1000000 iteration(s), 0.605 seconds, result= 1\nstrcspn(\"a.b\"): 1000000 iteration(s), 0.613 seconds, result= 1\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fmeasure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-forge%2Fmeasure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fmeasure/lists"}