{"id":15404538,"url":"https://github.com/k1low/stopw","last_synced_at":"2025-10-14T07:33:29.635Z","repository":{"id":53833308,"uuid":"521604305","full_name":"k1LoW/stopw","owner":"k1LoW","description":"A stopwatch library in Go for nested time measurement.","archived":false,"fork":false,"pushed_at":"2024-12-04T07:15:05.000Z","size":55,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-17T06:54:50.424Z","etag":null,"topics":["go","stopwatch","time"],"latest_commit_sha":null,"homepage":"","language":"Go","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/k1LoW.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"k1LoW","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2022-08-05T10:58:43.000Z","updated_at":"2025-01-22T04:11:39.000Z","dependencies_parsed_at":"2024-06-19T09:54:13.926Z","dependency_job_id":"b286de13-1727-4edb-b0e6-7379169a83f5","html_url":"https://github.com/k1LoW/stopw","commit_stats":{"total_commits":61,"total_committers":3,"mean_commits":"20.333333333333332","dds":0.08196721311475408,"last_synced_commit":"f20acced3dcbacaf0b860397f1ee0bd580d1cd48"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/k1LoW/stopw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fstopw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fstopw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fstopw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fstopw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k1LoW","download_url":"https://codeload.github.com/k1LoW/stopw/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fstopw/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018219,"owners_count":26086307,"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-10-14T02:00:06.444Z","response_time":60,"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":["go","stopwatch","time"],"created_at":"2024-10-01T16:13:35.510Z","updated_at":"2025-10-14T07:33:29.620Z","avatar_url":"https://github.com/k1LoW.png","language":"Go","funding_links":["https://github.com/sponsors/k1LoW"],"categories":[],"sub_categories":[],"readme":"# stopw [![Go Reference](https://pkg.go.dev/badge/github.com/k1LoW/stopw.svg)](https://pkg.go.dev/github.com/k1LoW/stopw) [![build](https://github.com/k1LoW/stopw/actions/workflows/ci.yml/badge.svg)](https://github.com/k1LoW/stopw/actions/workflows/ci.yml) ![Coverage](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/stopw/coverage.svg) ![Code to Test Ratio](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/stopw/ratio.svg) ![Test Execution Time](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/stopw/time.svg)\n\nA stopwatch library in Go for nested time measurement.\n\n## Usage\n\n``` go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/k1LoW/stopw\"\n)\n\nfunc main() {\n\tstopw.Start()\n\tstopw.Start(\"sub span A\")\n\t// do something for `sub span A`\n\tstopw.Start(\"sub span B\")\n\t// do something for `sub span A` or `sub span B`\n\tstopw.Start(\"sub span A\", \"sub sub span a\")\n\t// do something for `sub span A` or `sub span B` or `sub sub span a`\n\tstopw.Stop(\"sub span A\", \"sub sub span a\")\n\t// do something for `sub span A` or `sub span B`\n\tstopw.Stop(\"sub span span A\")\n\t// do something for `sub span B`\n\tstopw.Stop()\n\n\tr := stopw.Result()\n\tb, _ := json.MarshalIndent(r, \"\", \"  \")\n\tfmt.Println(string(b))\n\n\t// Output:\n\t// {\n\t//   \"id\": \"cbt1386v9mc80ofooblg\",\n\t//   \"started_at\": \"2009-11-10T23:00:00.436022+09:00\",\n\t//   \"stopped_at\": \"2009-11-10T23:00:00.436883+09:00\",\n\t//   \"elapsed\": 860375,\n\t//   \"breakdown\": [\n\t//     {\n\t//       \"id\": \"sub span A\",\n\t//       \"started_at\": \"2009-11-10T23:00:00.436153+09:00\",\n\t//       \"stopped_at\": \"2009-11-10T23:00:00.436594+09:00\",\n\t//       \"elapsed\": 441292,\n\t//       \"breakdown\": [\n\t//         {\n\t//           \"id\": \"sub sub span a\",\n\t//           \"started_at\": \"2009-11-10T23:00:00.436449+09:00\",\n\t//           \"stopped_at\": \"2009-11-10T23:00:00.436594+09:00\",\n\t//           \"elapsed\": 145500\n\t//         }\n\t//       ]\n\t//     },\n\t//     {\n\t//       \"id\": \"sub span B\",\n\t//       \"started_at\": \"2009-11-10T23:00:00.436303+09:00\",\n\t//       \"stopped_at\": \"2009-11-10T23:00:00.436883+09:00\",\n\t//       \"elapsed\": 580083\n\t//     }\n\t//   ]\n\t// }\n}\n```\n\n### Measure elapsed time of block\n\n``` go\nfunc () {\n\tdefer stopw.Start().Stop()\n\t// do something\n}()\nr := stopw.Result()\n[...]\n```\n\n### Measure separately\n\n``` go\na := stopw.New()\nb := stopw.New()\n\na.Start()\n// do something for a\na.Stop()\n\nb.Start()\n// do something for b\nb.Stop()\n\nra := a.Result()\nrb := b.Result()\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1low%2Fstopw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk1low%2Fstopw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1low%2Fstopw/lists"}