{"id":13562584,"url":"https://github.com/sebastianbergmann/php-timer","last_synced_at":"2026-02-06T06:10:44.215Z","repository":{"id":900515,"uuid":"656308","full_name":"sebastianbergmann/php-timer","owner":"sebastianbergmann","description":"Utility class for timing","archived":false,"fork":false,"pushed_at":"2025-12-31T16:29:08.000Z","size":65985,"stargazers_count":7748,"open_issues_count":0,"forks_count":63,"subscribers_count":19,"default_branch":"main","last_synced_at":"2026-02-02T08:57:27.942Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebastianbergmann.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"sebastianbergmann","liberapay":"sebastianbergmann","thanks_dev":"u/gh/sebastianbergmann","tidelift":"packagist/phpunit/php-timer"}},"created_at":"2010-05-08T10:40:25.000Z","updated_at":"2026-01-26T18:32:02.000Z","dependencies_parsed_at":"2023-07-05T19:03:10.123Z","dependency_job_id":"44bae3b8-a194-4048-ac40-96cb7319f391","html_url":"https://github.com/sebastianbergmann/php-timer","commit_stats":{"total_commits":422,"total_committers":13,"mean_commits":32.46153846153846,"dds":0.06398104265402849,"last_synced_commit":"7d0f6b33c3cf83a9319f7d2ede0f4453b476ca4d"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/sebastianbergmann/php-timer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianbergmann%2Fphp-timer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianbergmann%2Fphp-timer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianbergmann%2Fphp-timer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianbergmann%2Fphp-timer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebastianbergmann","download_url":"https://codeload.github.com/sebastianbergmann/php-timer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianbergmann%2Fphp-timer/sbom","scorecard":{"id":808522,"data":{"date":"2025-08-11","repo":{"name":"github.com/sebastianbergmann/php-timer","commit":"23036cd263bd4812edd4642cd866db831704821f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.2,"checks":[{"name":"Maintained","score":2,"reason":"3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Info: Found linked content: SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-23T12:28:27.436Z","repository_id":900515,"created_at":"2025-08-23T12:28:27.436Z","updated_at":"2025-08-23T12:28:27.436Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29153283,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T02:39:25.012Z","status":"ssl_error","status_checked_at":"2026-02-06T02:37:22.784Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-08-01T13:01:10.167Z","updated_at":"2026-02-06T06:10:44.174Z","avatar_url":"https://github.com/sebastianbergmann.png","language":"PHP","funding_links":["https://github.com/sponsors/sebastianbergmann","https://liberapay.com/sebastianbergmann","https://thanks.dev/u/gh/sebastianbergmann","https://tidelift.com/funding/github/packagist/phpunit/php-timer"],"categories":["PHP","类库"],"sub_categories":["时间/日期"],"readme":"# phpunit/php-timer\n\n[![Latest Stable Version](https://poser.pugx.org/phpunit/php-timer/v)](https://packagist.org/packages/phpunit/php-timer)\n[![CI Status](https://github.com/sebastianbergmann/php-timer/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/php-timer/actions)\n[![codecov](https://codecov.io/gh/sebastianbergmann/php-timer/branch/main/graph/badge.svg)](https://codecov.io/gh/sebastianbergmann/php-timer)\n\nUtility class for timing things, factored out of PHPUnit into a stand-alone component.\n\n## Installation\n\nYou can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):\n\n```\ncomposer require phpunit/php-timer\n```\n\nIf you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:\n\n```\ncomposer require --dev phpunit/php-timer\n```\n\n## Usage\n\n### Basic Timing\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse SebastianBergmann\\Timer\\Timer;\n\n$timer = new Timer;\n\n$timer-\u003estart();\n\nforeach (\\range(0, 100000) as $i) {\n    // ...\n}\n\n$duration = $timer-\u003estop();\n\nvar_dump(get_class($duration));\nvar_dump($duration-\u003easString());\nvar_dump($duration-\u003easSeconds());\nvar_dump($duration-\u003easMilliseconds());\nvar_dump($duration-\u003easMicroseconds());\nvar_dump($duration-\u003easNanoseconds());\n```\n\nThe code above yields the output below:\n\n```\nstring(32) \"SebastianBergmann\\Timer\\Duration\"\nstring(9) \"00:00.002\"\nfloat(0.002851062)\nfloat(2.851062)\nfloat(2851.062)\nint(2851062)\n```\n\n### Resource Consumption\n\n#### Explicit duration\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse SebastianBergmann\\Timer\\ResourceUsageFormatter;\nuse SebastianBergmann\\Timer\\Timer;\n\n$timer = new Timer;\n$timer-\u003estart();\n\nforeach (\\range(0, 100000) as $i) {\n    // ...\n}\n\nprint (new ResourceUsageFormatter)-\u003eresourceUsage($timer-\u003estop());\n```\n\nThe code above yields the output below:\n\n```\nTime: 00:00.002, Memory: 6.00 MB\n```\n\n#### Duration since PHP Startup (using unreliable `$_SERVER['REQUEST_TIME_FLOAT']`)\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse SebastianBergmann\\Timer\\ResourceUsageFormatter;\n\nforeach (\\range(0, 100000) as $i) {\n    // ...\n}\n\nprint (new ResourceUsageFormatter)-\u003eresourceUsageSinceStartOfRequest();\n```\n\nThe code above yields the output below:\n\n```\nTime: 00:00.002, Memory: 6.00 MB\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastianbergmann%2Fphp-timer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebastianbergmann%2Fphp-timer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastianbergmann%2Fphp-timer/lists"}