{"id":21446189,"url":"https://github.com/spazmodius/hrbench","last_synced_at":"2026-05-17T20:09:57.037Z","repository":{"id":143019017,"uuid":"146929259","full_name":"spazmodius/hrbench","owner":"spazmodius","description":"High-resolution micro-benchmarking in Node.js","archived":false,"fork":false,"pushed_at":"2019-03-17T16:10:00.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-23T11:23:42.926Z","etag":null,"topics":["module","node","testing"],"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/spazmodius.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":"2018-08-31T18:30:54.000Z","updated_at":"2019-03-17T16:10:01.000Z","dependencies_parsed_at":"2023-04-22T17:30:41.516Z","dependency_job_id":null,"html_url":"https://github.com/spazmodius/hrbench","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spazmodius%2Fhrbench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spazmodius%2Fhrbench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spazmodius%2Fhrbench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spazmodius%2Fhrbench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spazmodius","download_url":"https://codeload.github.com/spazmodius/hrbench/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955908,"owners_count":20374400,"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":["module","node","testing"],"created_at":"2024-11-23T02:42:17.775Z","updated_at":"2026-05-17T20:09:51.999Z","avatar_url":"https://github.com/spazmodius.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spaz's hrBench\r\n\r\nHigh-resolution micro-benchmarking in Node.js.\r\n\r\n## Install and Usage\r\n`npm install spazmodius/hrbench -D`\r\n\r\n```js\r\nconst Benchmark = require('@spazmodius/hrbench')\r\nconst crypto = require('crypto')\r\n\r\nBenchmark('Getting crypto bytes')\r\n\t.test('small', () =\u003e crypto.randomBytes(15))\r\n\t.test('medium', () =\u003e crypto.randomBytes(150))\r\n```\r\n\r\n## Concepts\r\n\r\nConcept | Definition\r\n---|---\r\nBenchmark | A suite of **tests** whose performance will be compared to each other.\r\nTest | A single operation in a **benchmark**, to be timed and compared to other tests in the same Benchmark.\r\nCycle | A single execution of a **test**. There are many cycles in a **round**.\r\nRound | Many repeated **cycles**, allowing enough time to pass for stable timing.\r\n\r\nA benchmark times each test by running it in a tight loop (a round).\r\nEach round will consist of enough cycles, typically, to take about 1/10th of a second.\r\nRounds themselves will be repeated as necessary to reach statistical confidence.\r\n\r\nOnce all of the tests have been timed to satisfactory statistical confidence,\r\ntheir timings will be summarized, ordered from fastest to slowest,\r\nand printed to the console.\r\n\r\n## Ansync tests\r\n\r\nNo, sorry.\r\n\r\n# API\r\n\r\n## [new] Benchmark( _[name], [options]_ )\r\n\r\nArgument | Type | Optional | Description\r\n---|---|:---:|---\r\n`name` | string | \u0026check; | Name of this benchmark.\r\n`options` | object | \u0026check; | Options\r\n\r\nStarts a benchmark, to compare the performance of a set of tests.\r\n\r\n### Options\r\n\r\n#### `name`\r\n\r\nNaming the benchmark is useful if there are multiple benchmarks in the file.\r\n\r\n#### `maxCycles`\r\n\r\nSet the maximum number of cycles per round.\r\n\r\nTypically, the number of cycles is automatically estimated so as to produce rounds approximately 1/10th of a second each.\r\nHowever, limiting the number of cycles per round is useful for memory-intensive tests,\r\nsince there will be no garbage-collection between cycles during a round.\r\n\r\n## benchmark.test( _[name], op, [noop]_ )\r\n\r\nArgument | Type | Optional | Description\r\n---|---|:---:|---\r\n`name` | string | \u0026check; | Name of this test.\r\n`op` | function | | The operation to time.\r\n`noop` | function or null | \u0026check; | Operation that represents doing nothing.\r\n\r\nAdds a test to the benchmark.\r\n\r\nIf a name is not specified, then one will be generated from the name or contents of the operation.\r\n\r\nThe `noop` function will be timed just like the operation, and subtracted from the results.\r\nThis will calibrate for the overhead of looping and invoking the operation.\r\nBy default, `noop` is an empty function call.\r\nSee [Demo3](./demo/demo3.js) for an example of a non-trivial `noop`.\r\n\r\nHowever, passing `null` will time an empty loop without any function call at all.\r\nThis has the effect of including the cost of invocation in the reported results.\r\nSee [Demo1](./demo/demo1.js) for an example of where this might be useful.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspazmodius%2Fhrbench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspazmodius%2Fhrbench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspazmodius%2Fhrbench/lists"}