{"id":26826722,"url":"https://github.com/hslam/timer","last_synced_at":"2025-08-11T17:44:51.315Z","repository":{"id":54374638,"uuid":"210181481","full_name":"hslam/timer","owner":"hslam","description":"Package timer provides functionality for measuring time. Much lower CPU overhead when using use_cgo tags during the idle period of system.","archived":false,"fork":false,"pushed_at":"2021-05-19T14:59:45.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-07-27T18:04:44.937Z","etag":null,"topics":["go","golang","sleep","ticker","time","timer"],"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/hslam.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}},"created_at":"2019-09-22T16:47:33.000Z","updated_at":"2021-05-19T14:59:48.000Z","dependencies_parsed_at":"2022-08-13T13:50:12.496Z","dependency_job_id":null,"html_url":"https://github.com/hslam/timer","commit_stats":null,"previous_names":[],"tags_count":2,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Ftimer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Ftimer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Ftimer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Ftimer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hslam","download_url":"https://codeload.github.com/hslam/timer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246313695,"owners_count":20757446,"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":["go","golang","sleep","ticker","time","timer"],"created_at":"2025-03-30T11:30:44.581Z","updated_at":"2025-03-30T11:30:45.121Z","avatar_url":"https://github.com/hslam.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# timer\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/hslam/timer)](https://pkg.go.dev/github.com/hslam/timer)\n[![Build Status](https://github.com/hslam/timer/workflows/build/badge.svg)](https://github.com/hslam/timer/actions)\n[![codecov](https://codecov.io/gh/hslam/timer/branch/master/graph/badge.svg)](https://codecov.io/gh/hslam/timer)\n[![Go Report Card](https://goreportcard.com/badge/github.com/hslam/timer)](https://goreportcard.com/report/github.com/hslam/timer)\n[![LICENSE](https://img.shields.io/github/license/hslam/timer.svg?style=flat-square)](https://github.com/hslam/timer/blob/master/LICENSE)\n\nPackage timer provides functionality for measuring time. Much lower CPU overhead when using use_cgo tags during the idle period of system.\n\n## Feature\n* cgo/go\n* Ticker\n* TickFunc\n* Timer\n* Sleep\n* After\n\n## Get started\n\n### Install\n```\ngo get github.com/hslam/timer\n```\n### Import\n```\nimport \"github.com/hslam/timer\"\n```\n### Usage\n#### Example\n```go\npackage main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"github.com/hslam/timer\"\n)\n\nfunc main() {\n\tt := *flag.String(\"t\", \"Sleep\", \"use timer\")\n\tflag.Parse()\n\tfmt.Println(timer.Tag)\n\tswitch t {\n\tcase \"Ticker\":\n\t\tt := timer.NewTicker(timer.Millisecond)\n\t\tdefer t.Stop()\n\t\tfor range t.C {\n\t\t\t//todo\n\t\t}\n\tcase \"TickFunc\":\n\t\tt := timer.TickFunc(timer.Millisecond, func() {\n\t\t\t//todo\n\t\t})\n\t\tdefer t.Stop()\n\t\tselect {}\n\tcase \"Timer\":\n\t\tt := timer.NewTimer(timer.Millisecond)\n\t\tdefer t.Stop()\n\t\tfor range t.C {\n\t\t\tt.Reset(timer.Millisecond)\n\t\t\t//todo\n\t\t}\n\tcase \"Sleep\":\n\t\tfor {\n\t\t\ttimer.Sleep(timer.Millisecond)\n\t\t\t//todo\n\t\t}\n\tcase \"After\":\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase \u003c-timer.After(timer.Millisecond):\n\t\t\t\t//todo\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tfmt.Println(\"use Ticker, TickFunc, Timer, Sleep or After\")\n\t}\n}\n```\n\n### Build\n#### go\n```\ngo build\n```\n#### cgo\n```\ngo build -tags=use_cgo\n```\n\n### License\nThis package is licensed under a MIT license (Copyright (c) 2019 Meng Huang)\n\n\n### Author\ntimer was written by Meng Huang.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslam%2Ftimer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhslam%2Ftimer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslam%2Ftimer/lists"}