{"id":16531380,"url":"https://github.com/marcbachmann/hrtime-milliseconds","last_synced_at":"2025-06-23T07:01:59.660Z","repository":{"id":57267118,"uuid":"95485961","full_name":"marcbachmann/hrtime-milliseconds","owner":"marcbachmann","description":"Calculates a diff in milliseconds between invocations.","archived":false,"fork":false,"pushed_at":"2023-12-15T14:53:41.000Z","size":13,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-06T00:51:24.189Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcbachmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-06-26T20:19:42.000Z","updated_at":"2019-11-14T19:11:21.000Z","dependencies_parsed_at":"2023-12-15T15:49:28.659Z","dependency_job_id":"ef87d461-c308-4b2e-9dbe-de128813361f","html_url":"https://github.com/marcbachmann/hrtime-milliseconds","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/marcbachmann/hrtime-milliseconds","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Fhrtime-milliseconds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Fhrtime-milliseconds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Fhrtime-milliseconds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Fhrtime-milliseconds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcbachmann","download_url":"https://codeload.github.com/marcbachmann/hrtime-milliseconds/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Fhrtime-milliseconds/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261433936,"owners_count":23157196,"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-10-11T18:08:41.251Z","updated_at":"2025-06-23T07:01:54.650Z","avatar_url":"https://github.com/marcbachmann.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# hrtime-milliseconds\n\nCalculates a diff in milliseconds between invocations. Originally I wanted to use `process.hrtime`, but it looks like `Date.now` is faster since it doesn't need any conversion.\n\n### Usage\n\n```\nconst start = require('hrtime-milliseconds')\n\n// Create an instance\nconst diff = start()\n\n// Then invoke the returned function to get the time since its' creation\n// It returns an integer that defines how many milliseconds passed (here it's 0 as we're in the same tick)\nconsole.log(diff())\n\nsetTimeout(function () {\n  // second invocation returns new diff since start, so we'll see 100\n  console.log(diff())\n}, 100)\n```\n\n\nIn case you need nanosecond precision, please use https://github.com/sindresorhus/time-span.\n\n### Benchmark\n\n```\nNANOBENCH version 2\n\u003e /Users/marcbachmann/.nvm/versions/node/v8.1.2/bin/node bench.js\n\n# 10 million operations using Date.now\nok ~1.74 s (1 s + 740748587 ns)\n\n# 10 million using wrapped process.hrtime\nok ~1.99 s (1 s + 985111399 ns)\n\n# 10 million operations directly using process.hrtime, without conversion\nok ~1.54 s (1 s + 540457122 ns)\n\nall benchmarks completed\nok ~5.27 s (5 s + 266317108 ns)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcbachmann%2Fhrtime-milliseconds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcbachmann%2Fhrtime-milliseconds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcbachmann%2Fhrtime-milliseconds/lists"}