{"id":13605167,"url":"https://github.com/choojs/nanotiming","last_synced_at":"2025-04-12T02:32:56.460Z","repository":{"id":43642933,"uuid":"88270816","full_name":"choojs/nanotiming","owner":"choojs","description":"⏲ - Small timing library","archived":false,"fork":false,"pushed_at":"2018-04-16T08:48:51.000Z","size":60,"stargazers_count":35,"open_issues_count":4,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-26T01:54:34.070Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/choojs.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":"2017-04-14T13:42:12.000Z","updated_at":"2022-12-19T08:48:42.000Z","dependencies_parsed_at":"2022-09-12T11:44:30.721Z","dependency_job_id":null,"html_url":"https://github.com/choojs/nanotiming","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanotiming","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanotiming/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanotiming/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanotiming/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/choojs","download_url":"https://codeload.github.com/choojs/nanotiming/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223489748,"owners_count":17153822,"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-08-01T19:00:55.361Z","updated_at":"2024-11-07T09:31:34.998Z","avatar_url":"https://github.com/choojs.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# nanotiming [![stability][0]][1]\n[![npm version][2]][3] [![build status][4]][5]\n[![downloads][8]][9] [![js-standard-style][10]][11]\n\nSmall timing library. Useful to integrate into libraries that have multiple\nmethods. Works both in the browser and Node. To use this in Node, make sure you\nare using v8.5.0 or greater.\n\n## Usage\n```js\nvar nanotiming = require('nanotiming')\n// require 'perf_hooks' for Node environment\n// var performance = require('perf_hooks').performance\n\nvar timing = nanotiming('my-loop') // Start profiling\n\nvar i = 1000\nwhile (--i) console.log(i)\n\n// Stop profiling\ntiming()\n\n// in the browser\nvar timings = window.performance.getEntries()\nvar timing = timings[timings.length - 1]\nconsole.log(timing.name, timing.duration) // log the last entry\nwindow.performance.clearMeasures(timing.name)    // be a good citizen and free after use\n\n// in Node \nvar timings = performance.getEntries()\nvar timing = timings[timings.length - 1]\nconsole.log(timing.name, timing.duration) // log the last entry\nperformance.clearMeasures(timing.name)    // be a good citizen and free after use\n```\n\n## Timing names\nTimings inside the view are appended with a unique UUID so they can be cleared\nindividually. While there's no strict format for timing formats, we recommend\nusing a format along these lines:\n```txt\nchoo.render [12356778]\nchoo.route('/') [13355671]\nchoo.emit('log:debug') [13355675]\n```\n\n## Disabling timings\nPerformance timers are still a somewhat experimental technology. While they're\na great idea conceptually, there might be bugs. To disable timings complete, in\nthe browser set:\n```js\nwindow.localStorage.DISABLE_NANOTIMING = true\n```\nAlternatively, in Node set:\n```js\nprocess.env.DISABLE_NANOTIMING = true\n```\n\n## API\n### `endTiming = nanotiming(name)`\nStart a new timing.\n\n### `endTiming.uuid`\nThe unique ID created for the timing.\n\n### `endTiming([cb(err, name)])`\nClose the timing. Measuring the timing is done inside a `requestIdleCallback()`\n(browser) or `setTimeout` (node) tick, so it might not be available\nimmediately. If a callback is passed it will be called with an error (if\nmeasuring wasn't successful) and the timing's name.\n\n## License\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square\n[1]: https://nodejs.org/api/documentation.html#documentation_stability_index\n[2]: https://img.shields.io/npm/v/nanotiming.svg?style=flat-square\n[3]: https://npmjs.org/package/nanotiming\n[4]: https://img.shields.io/travis/choojs/nanotiming/master.svg?style=flat-square\n[5]: https://travis-ci.org/choojs/nanotiming\n[6]: https://img.shields.io/codecov/c/github/choojs/nanotiming/master.svg?style=flat-square\n[7]: https://codecov.io/github/choojs/nanotiming\n[8]: http://img.shields.io/npm/dm/nanotiming.svg?style=flat-square\n[9]: https://npmjs.org/package/nanotiming\n[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[11]: https://github.com/feross/standard\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoojs%2Fnanotiming","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchoojs%2Fnanotiming","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoojs%2Fnanotiming/lists"}