{"id":13447821,"url":"https://github.com/node-modules/time-profile","last_synced_at":"2025-06-14T03:07:54.991Z","repository":{"id":134887454,"uuid":"132428506","full_name":"node-modules/time-profile","owner":"node-modules","description":"Measuring execution time of functions","archived":false,"fork":false,"pushed_at":"2018-07-02T07:53:33.000Z","size":20,"stargazers_count":16,"open_issues_count":0,"forks_count":6,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-05-28T11:04:38.265Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/node-modules.png","metadata":{"files":{"readme":"README.md","changelog":"History.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}},"created_at":"2018-05-07T08:12:04.000Z","updated_at":"2023-07-12T11:33:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"d948b31e-7257-4573-83d3-d97c3f624a44","html_url":"https://github.com/node-modules/time-profile","commit_stats":null,"previous_names":["node-modules/time-profile"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/node-modules/time-profile","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Ftime-profile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Ftime-profile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Ftime-profile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Ftime-profile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-modules","download_url":"https://codeload.github.com/node-modules/time-profile/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Ftime-profile/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259752078,"owners_count":22905972,"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":"2024-07-31T05:01:27.671Z","updated_at":"2025-06-14T03:07:54.934Z","avatar_url":"https://github.com/node-modules.png","language":"JavaScript","readme":"# time-profile\nMeasuring execution time of functions\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/time-profile.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/time-profile\n[travis-image]: https://img.shields.io/travis/node-modules/time-profile.svg?style=flat-square\n[travis-url]: https://travis-ci.org/node-modules/time-profile\n[codecov-image]: https://codecov.io/github/node-modules/time-profile/coverage.svg?branch=master\n[codecov-url]: https://codecov.io/github/node-modules/time-profile?branch=master\n[david-image]: https://img.shields.io/david/node-modules/time-profile.svg?style=flat-square\n[david-url]: https://david-dm.org/node-modules/time-profile\n[snyk-image]: https://snyk.io/test/npm/time-profile/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/time-profile\n[download-image]: https://img.shields.io/npm/dm/time-profile.svg?style=flat-square\n[download-url]: https://npmjs.org/package/time-profile\n\nA Tool to help you to measure execution time of functions.\n\n## Install\n\n```bash\n$ npm install time-profile\n```\n\n## Usage\n\n```js\nconst timeProfile = require('time-profile');\n\nconst profiler = timeProfile.getProfiler('aProfiler');\n\nprofiler.start('app launch');\n// ... do work\n\nprofiler.start('load plugins');\n// ... load plugins\nprofiler.end('load plugins');\n\nprofiler.start('load services');\n// ... load services\nprofiler.end('load services');\n\nprofiler.start('init');\n// ... init\nprofiler.end('init');\n\n// ...\nprofiler.end('app launch');\n\n// in the end, you can dump the profile data to a json\nconst json = profiler.toJSON(); // [ Entry { name, start, end, duration, pid }, ... ]\n\n// also you can print the profile timeline\nconsole.log(profiler.toString('this is timeline:'));\n\n// you shoud destroy it when it's not needed anymore\nprofiler.destroy();\n```\n\n```bash\nthis is timeline:\n▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇  [172ms] - app launch\n  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇  [91ms] - load plugins\n   ▇▇▇▇▇▇▇▇▇▇▇▇▇  [47ms] - load services\n                 ▇▇▇▇▇▇▇▇▇▇▇  [41ms] - init\n```\n\nProfilers are created based on tags, and can be accessed from any scope. You can also use a simplified `profiler.profile(fn, ...params)` to measure a specific async or sync function\n\n```js\nconst profiler = timeProfile.getInstance('anotherProfiler');\nconst sleep = ms =\u003e new Promise(r =\u003e setTimeout(r, ms));\nconst syncFn = (a, b) =\u003e a + b;\nawait profiler.profile(sleep, 10);\nawait profiler.profile(syncFn, 1, 3);\n\n// You can even specify a different toString width output value\nconsole.log(profiler.toString('this is timeline:', 40));\n```\n\n```bash\n▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇  [9.703106 ms] - sleep\n                                                                       ▇  [56.503 μs] - syncFn\n```\n\nOr use `profiler.profileTagged(fn, tag, ...params)` if you want to change the tag or profile and anonymous function  \n\n```js\nawait profiler.profileTagged(sleep, 'tagA', 100);\nawait profiler.profileTagged(sleep, 'tagB', 125);\nawait profiler.profileTagged(sleep, null, 150);\nconsole.log(profiler.toString('this is timeline:'));\n```\n\n\n```bash\nthis is timeline:\n▇▇▇▇▇▇▇▇▇▇▇▇▇  [101.674214 ms] - tagA\n                       ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇  [125.914368 ms] - tagB\n                                                   ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇  [150.5361 ms] - sleep\n```\n\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Ftime-profile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-modules%2Ftime-profile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Ftime-profile/lists"}