{"id":17398449,"url":"https://github.com/vweevers/gctime","last_synced_at":"2026-05-07T18:48:03.212Z","repository":{"id":55828510,"uuid":"148218575","full_name":"vweevers/gctime","owner":"vweevers","description":"Record time spent on GC in high resolution.","archived":false,"fork":false,"pushed_at":"2020-12-11T17:46:07.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T21:39:05.671Z","etag":null,"topics":["garbage-collection","gc","nodejs","nodejs-addon","npm-package","prebuilt-binaries"],"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/vweevers.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":"2018-09-10T21:00:02.000Z","updated_at":"2020-02-05T12:18:27.000Z","dependencies_parsed_at":"2022-08-15T07:31:19.492Z","dependency_job_id":null,"html_url":"https://github.com/vweevers/gctime","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/vweevers%2Fgctime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fgctime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fgctime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fgctime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/gctime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246237436,"owners_count":20745348,"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":["garbage-collection","gc","nodejs","nodejs-addon","npm-package","prebuilt-binaries"],"created_at":"2024-10-16T14:56:39.515Z","updated_at":"2026-05-07T18:47:58.190Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gctime\n\n\u003e **Record time spent on GC in high resolution.**  \n\u003e Yields a statistic set with `min`, `max` and `sum` of duration and `size` (number of cycles).\n\n[![npm status](http://img.shields.io/npm/v/gctime.svg)](https://www.npmjs.org/package/gctime)\n[![node](https://img.shields.io/node/v/gctime.svg)](https://www.npmjs.org/package/gctime)\n[![Travis build status](https://img.shields.io/travis/vweevers/gctime.svg?label=travis)](http://travis-ci.org/vweevers/gctime)\n[![AppVeyor build status](https://img.shields.io/appveyor/ci/vweevers/gctime.svg?label=appveyor)](https://ci.appveyor.com/project/vweevers/gctime)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Dependency status](https://img.shields.io/david/vweevers/gctime.svg)](https://david-dm.org/vweevers/gctime)\n\n## Usage\n\nContinuously log GC cycles and duration:\n\n```js\nconst gctime = require('gctime')\nconst nano = require('nanoseconds')\nconst diffy = require('diffy')()\nconst fmt = require('util').format\nconst stats = gctime.get()\n\ndiffy.render(function () {\n  // Update stats. Alternatively call .get() to get a new object.\n  gctime.accumulate(stats)\n\n  return fmt(\n    'cycles: %d. min: %dns. max: %dns. avg: %dns',\n    stats.size,\n    nano(stats.min),\n    nano(stats.max),\n    nano(stats.sum) / stats.size | 0\n  )\n})\n\ngctime.start()\n\nsetInterval(() =\u003e Array(1e6).fill(1), 100)\nsetInterval(() =\u003e diffy.render(), 500)\n```\n\n```\n$ node example.js\ncycles: 174. min: 45488ns. max: 843813ns. avg: 131384ns\n```\n\nWhen you're done, call `gctime.stop()`. For a single run, you can skip `get()` as `stop()` returns stats too: `stats = gctime.stop()`.\n\nThe statistics follow the format of [`process.hrtime()`](https://nodejs.org/api/process.html#process_process_hrtime_time): an array of `[seconds, nanoseconds]` where `nanoseconds` is the remaining part of the time that can't be represented in second precision.\n\nThe state of `start()`, `get()` and `stop()` is global. They throw if already started or stopped, respectively.\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install gctime\n```\n\n## License\n\n[MIT](LICENSE) © 2017-present Vincent Weevers. Contains 8 lines of code from Node.js [© many people](https://github.com/nodejs/node/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fgctime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Fgctime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fgctime/lists"}