{"id":15679780,"url":"https://github.com/bnomei/kirby3-stopwatch","last_synced_at":"2025-04-19T20:31:18.380Z","repository":{"id":37549199,"uuid":"202987665","full_name":"bnomei/kirby3-stopwatch","owner":"bnomei","description":"Profile your Kirby CMS code with precision in milliseconds (or seconds)","archived":true,"fork":false,"pushed_at":"2024-11-23T16:58:33.000Z","size":145,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-18T05:44:44.677Z","etag":null,"topics":["kirby-cms","kirby-plugin","measure","milliseconds","profile","stopwatch","usleep"],"latest_commit_sha":null,"homepage":"","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/bnomei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"bnomei","patreon":"bnomei","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://buymeacoff.ee/bnomei","https://paypal.me/bnomei"]}},"created_at":"2019-08-18T10:11:16.000Z","updated_at":"2024-11-23T18:56:30.000Z","dependencies_parsed_at":"2024-01-23T00:16:51.733Z","dependency_job_id":"792a10a8-d43b-410a-9fda-0f1bceed7057","html_url":"https://github.com/bnomei/kirby3-stopwatch","commit_stats":{"total_commits":23,"total_committers":2,"mean_commits":11.5,"dds":0.3913043478260869,"last_synced_commit":"91743d93568c7f7ed0d5732f65d2747f6ba39f81"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-stopwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-stopwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-stopwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-stopwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bnomei","download_url":"https://codeload.github.com/bnomei/kirby3-stopwatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249794796,"owners_count":21326774,"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":["kirby-cms","kirby-plugin","measure","milliseconds","profile","stopwatch","usleep"],"created_at":"2024-10-03T16:36:17.486Z","updated_at":"2025-04-19T20:31:18.373Z","avatar_url":"https://github.com/bnomei.png","language":"PHP","funding_links":["https://github.com/sponsors/bnomei","https://patreon.com/bnomei","https://buymeacoff.ee/bnomei","https://paypal.me/bnomei"],"categories":[],"sub_categories":[],"readme":"# Kirby Stopwatch\n\n![Release](https://flat.badgen.net/packagist/v/bnomei/kirby3-stopwatch?color=ae81ff)\n![Downloads](https://flat.badgen.net/packagist/dt/bnomei/kirby3-stopwatch?color=272822)\n[![Build Status](https://flat.badgen.net/travis/bnomei/kirby3-stopwatch)](https://travis-ci.com/bnomei/kirby3-stopwatch)\n[![Coverage Status](https://flat.badgen.net/coveralls/c/github/bnomei/kirby3-stopwatch)](https://coveralls.io/github/bnomei/kirby3-stopwatch)\n[![Maintainability](https://flat.badgen.net/codeclimate/maintainability/bnomei/kirby3-stopwatch)](https://codeclimate.com/github/bnomei/kirby3-stopwatch)  \n[![Twitter](https://flat.badgen.net/badge/twitter/bnomei?color=66d9ef)](https://twitter.com/bnomei)\n\nProfile your Kirby CMS code with precision in milliseconds (or seconds). \n\n## Installation\n\n- unzip [master.zip](https://github.com/bnomei/kirby3-stopwatch/archive/master.zip) as folder `site/plugins/kirby3-stopwatch` or\n- `git submodule add https://github.com/bnomei/kirby3-stopwatch.git site/plugins/kirby3-stopwatch` or\n- `composer require bnomei/kirby3-stopwatch`\n\n## Works well with\n\n- [Janitor Plugin](https://github.com/bnomei/kirby3-janitor)\n- [Monolog Plugin](https://github.com/bnomei/kirby3-monolog)\n\n## Usage Site Method\n\nPlease read the [Symfony Stopwatch Component Docs](https://symfony.com/doc/current/components/stopwatch.html) since this plugin is just a soft wrapper around it. Some Examples:\n\n**Event Duration**\n```php\nsite()-\u003estopwatch()-\u003estart('myevent');\nsleep(1);\nsite()-\u003estopwatch()-\u003estop('myevent');\necho site()-\u003estopwatch()-\u003eduration('myevent') . PHP_EOL; // float | int\n```\n\n**Event with Laps aka Periods**\n```php\n$eventName = 'my event with laps';\n$stopwatch = site()-\u003estopwatch();\n$stopwatch-\u003estart($eventName);\nforeach ([random_int(100,500),random_int(100,500),random_int(100,500)] as $time) {\n    usleep($time);\n    $stopwatch-\u003elap($eventName);\n}\nusleep(100);\n$stopwatch-\u003estop($eventName);\n$totalDuration = $stopwatch-\u003eduration($eventName); // float | int\necho $totalDuration . PHP_EOL;\nforeach ($stopwatch-\u003egetEvent($eventName)-\u003egetPeriods() as $period) {\n    echo $period-\u003egetDuration() . PHP_EOL;  // float | int\n}\n```\n\n## Usage PHP Class\n\nYou can use the provided php class in your own classes if you make sure the class is loaded before you call it. This can be done in installing this plugin using composer or in manually requiring it with [Kirby's class loader](https://getkirby.com/docs/reference/templates/helpers/load).\n\n```php\n$stopwatch = \\Bnomei\\Stopwatch::singleton();\n$stopwatch-\u003estart('my event with laps');\nsleep(1);\n$stopwatch-\u003estop('my event with laps');\n$duration = $stopwatch-\u003eduration('my event with laps'); // float | int\n```\n\n## Settings\n\n| bnomei.stopwatch.           | Default        | Description               |            \n|---------------------------|----------------|---------------------------| \n| precision | `true` | measure microseconds as float or int seconds. |\n\n\u003e NOTE: This plugin defaults to measuring in milliseconds but the symfony component does not.\n\n## Dependencies\n\n- [symfony/stopwatch](https://github.com/symfony/stopwatch)\n\n## Disclaimer\n\nThis plugin is provided \"as is\" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please [create a new issue](https://github.com/bnomei/kirby3-stopwatch/issues/new).\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n\nIt is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnomei%2Fkirby3-stopwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbnomei%2Fkirby3-stopwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnomei%2Fkirby3-stopwatch/lists"}