{"id":24600256,"url":"https://github.com/ejoffe/profiletimer","last_synced_at":"2025-03-18T07:12:54.126Z","repository":{"id":57581837,"uuid":"369964608","full_name":"ejoffe/profiletimer","owner":"ejoffe","description":"A simple utility tool to profile go code.","archived":false,"fork":false,"pushed_at":"2021-08-04T00:32:45.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-24T13:35:16.267Z","etag":null,"topics":[],"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/ejoffe.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":"2021-05-23T05:01:03.000Z","updated_at":"2021-08-04T00:32:25.000Z","dependencies_parsed_at":"2022-09-26T19:31:30.704Z","dependency_job_id":null,"html_url":"https://github.com/ejoffe/profiletimer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejoffe%2Fprofiletimer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejoffe%2Fprofiletimer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejoffe%2Fprofiletimer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejoffe%2Fprofiletimer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ejoffe","download_url":"https://codeload.github.com/ejoffe/profiletimer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244173554,"owners_count":20410300,"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":[],"created_at":"2025-01-24T13:29:42.664Z","updated_at":"2025-03-18T07:12:54.098Z","avatar_url":"https://github.com/ejoffe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Profile Timer\n=============\n\nA simple utility tool to profile go code.\n\nProfile timer works like a stop watch, you start the timer and call the step function everytime you want to add a new data point. At the end you can print a summary of all the steps and the amount of time each step took.\n\nInstallation\n------------\n```bash\ngo get -u github.com/ejoffe/profiletimer\n```\n\nUsage\n-----\n```Go\nfunc main() {\n    timer := profiletimer.StartProfileTimer()\n\n    doSomeStuff()\n    timer.Step(\"doSomeStuff\")\n    doSomeMoreStuff()\n    timer.Step(\"doSomeMoreStuff\")\n    doEvenMoreStuff()\n    timer.Step(\"doEvenMoreStuff\")\n\n    timer.ShowResults()\n}\n```\n\nThe code above will print out a summary to stdout with the amount of time each step took.\n```\ndoSomeStuff     : 2165.694534ms\ndoSomeMoreStuff : 11.568080ms\ndoEvenMoreStuff : 541.535541ms\n-------------------------------\ntotal           : 2718.798155ms\n```\n\nMiddleware\n----------\n```Go\nfunc main() {\n    router := chi.NewRouter()\n    router.Use(profiletimer.TimerMiddleware)\n    router.Get(\"/\", get)\n    http.ListenAndServe(\":80\", router)\n}\n\nfunc get(w http.ResponseWriter, r *http.Request) {\n    timer := profiletimer.TimerFromContext(r.Context())\n    doSomeStuff()\n    timer.Step(\"doSomeStuff\")\n    doSomeMoreStuff()\n    timer.Step(\"doSomeMoreStuff\")\n    doEvenMoreStuff()\n    timer.Step(\"doEvenMoreStuff\")\n}\n```\n\n### Noop Timer\n\n\nOften, you'll want to leave the profile step functions in the code and only run them in debug or profile mode. In this case you can use `StartProfileTimer()` when in debug mode, and otherwise instantiate the timer using `StartNoopTimer()`. \n\nLicense\n-------\n\n-\t[MIT License](LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejoffe%2Fprofiletimer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fejoffe%2Fprofiletimer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejoffe%2Fprofiletimer/lists"}