{"id":17148925,"url":"https://github.com/planttheidea/benchee","last_synced_at":"2025-10-28T14:13:22.262Z","repository":{"id":33169765,"uuid":"153792961","full_name":"planttheidea/benchee","owner":"planttheidea","description":"Simple benchmarks in both node and browser","archived":false,"fork":false,"pushed_at":"2024-03-28T17:36:43.000Z","size":1202,"stargazers_count":27,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T10:12:48.485Z","etag":null,"topics":["benchmark","javascript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/planttheidea.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-19T14:08:40.000Z","updated_at":"2024-05-19T00:20:03.000Z","dependencies_parsed_at":"2024-02-12T02:31:53.733Z","dependency_job_id":"b3798ab2-200c-4fc7-b629-1e3cfc776280","html_url":"https://github.com/planttheidea/benchee","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planttheidea%2Fbenchee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planttheidea%2Fbenchee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planttheidea%2Fbenchee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planttheidea%2Fbenchee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/planttheidea","download_url":"https://codeload.github.com/planttheidea/benchee/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695482,"owners_count":21146956,"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":["benchmark","javascript"],"created_at":"2024-10-14T21:30:29.618Z","updated_at":"2025-10-28T14:13:17.241Z","avatar_url":"https://github.com/planttheidea.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# benchee\n\nSimple benchmarks in both node and browser\n\n## Table of contents\n\n- [Requirements](#requirements)\n- [Usage](#usage)\n- [Benchmark groups](#benchmark-groups)\n- [Statistics](#statistics)\n- [Options](#options)\n  - [delay](#delay)\n  - [minIterations](#miniterations)\n  - [minTime](#mintime)\n  - [onComplete](#oncomplete)\n  - [onGroupComplete](#ongroupcomplete)\n  - [onGroupStart](#ongroupstart)\n  - [onResult](#onresult)\n  - [type](#type)\n- [Support](#support)\n  - [Browser](#browser)\n  - [Node](#node)\n- [Development](#development)\n\n## Requirements\n\n`benchee` requires that `Promise` is available globally. If using an environment that does not support it, you should polyfill prior to importing `benchee`.\n\n## Usage\n\n```javascript\nimport { benchmark, createSuite } from \"benchee\";\n\n// the functions to benchmark\nconst add = (a, b) =\u003e a + b;\nconst subtract = (a, b) =\u003e a - b;\n\n// create an individual benchmark\nbenchmark(\"add\", () =\u003e add(1, 2)).then(results =\u003e console.log(results));\n\n/*\n{\n  \"stats\": {\n    \"elapsed\": 677,\n    \"endTime\": 1540050973491,\n    \"startTime\": 1540050972814,\n    \"iterations\": 82165907,\n    \"ops\": 121367661,\n    \"tpe\": 0.00000823942708987561\n  },\n  \"name\": \"add\"\n}\n*/\n\n// or create a suite of benchmarks\ncreateSuite()\n  .add(\"add\", () =\u003e add(1, 2))\n  .add(\"subtract\", () =\u003e subtract(1, 2))\n  .run()\n  .then(results =\u003e console.log(results));\n\n/*\n{\n  \"ungrouped\": [\n    {\n      \"stats\": {\n        \"elapsed\": 802,\n        \"endTime\": 1540050973617,\n        \"startTime\": 1540050972815,\n        \"iterations\": 28777534,\n        \"ops\": 35882211,\n        \"tpe\": 0.000027868961947886152\n      },\n      \"name\": \"add\"\n    },\n    {\n      \"stats\": {\n        \"elapsed\": 750,\n        \"endTime\": 1540050974473,\n        \"startTime\": 1540050973723,\n        \"iterations\": 106326932,\n        \"ops\": 141769242,\n        \"tpe\": 0.000007053716174186235\n      },\n      \"name\": \"subtract\"\n    }\n  ]\n}\n*/\n```\n\nThe results contract is `Promise`-based, however you can also access the results in a [callback format](#oncomplete) if preferred.\n\n## Benchmark groups\n\nIn addition to running standard benchmarks, you can group benchmarks together within the same suite. The results of each group can be accessed through the [`onGroupComplete` callback](#ongroupcomplete), and will namespaced under the group name in the final results.\n\nTo apply a group, simply add a group name as the second parameter to your test.\n\n```javascript\ncreateSuite()\n  .add(\"add\", \"math\", () =\u003e add(1, 2))\n  .add(\"trim\", \"string\", () =\u003e \"  trimmed  \".trim())\n  .run()\n  .then(results =\u003e console.log(results));\n\n/*\n{\n  \"math\": [\n    {\n      \"stats\": {\n        \"elapsed\": 888,\n        \"endTime\": 1540051045206,\n        \"startTime\": 1540051044318,\n        \"iterations\": 38415463,\n        \"ops\": 43260656,\n        \"tpe\": 0.000023115691720284616\n      },\n      \"name\": \"add\"\n    }\n  ],\n  \"string\": [\n    {\n      \"stats\": {\n        \"elapsed\": 568,\n        \"endTime\": 1540051045880,\n        \"startTime\": 1540051045312,\n        \"iterations\": 15363261,\n        \"ops\": 27047994,\n        \"tpe\": 0.00003697131748266205\n      },\n      \"name\": \"trim\"\n    }\n  ]\n}\n*/\n```\n\n## Statistics\n\nStatistics for each benchmark have the following shape:\n\n```javascript\n{\n  // time of total benchmark run\n  elapsed: number;\n  // timestamp of benchmark complete\n  endTime: number;\n  // number of operations executed in benchmark\n  iterations: number;\n  // operations per second calculation\n  ops: number;\n  // time per execution calculation\n  tpe: number;\n  // timestamp of benchmark start\n  startTime: number;\n}\n```\n\n## Options\n\n#### delay\n\nThe time wait between execution of benchmark [groups](#benchmark-groups) _(defaults to 100ms)_\n\n#### minIterations\n\nThe minimum number of iterations that need to occur before the benchmark is considered complete _(defaults to 10)_\n\n#### minTime\n\nThe minimum amount of time that needs to elapse before the benchmark is considered complete _(defaults to 500ms)_\n\n**NOTE**: This is ignored when [`type`](#type) is set to `fixed`.\n\n#### onComplete\n\nFunction called when suite has finished running. This is the callback method to receive results, if preferred over the standard promised-based method.\n\n```javascript\nonComplete: (results: Benchee.Results) =\u003e void;\n```\n\n#### onGroupComplete\n\nFunction called when a given [group](#benchmark-groups) has completed all of its benchmarks.\n\n```javascript\nonGroupComplete: (results: Benchee.ResultsGroup) =\u003e void;\n```\n\n#### onGroupStart\n\nFunction called when a given [group](#benchmark-groups) has started running its benchmarks.\n\n```javascript\nonGroupStart: (group: string) =\u003e void;\n```\n\n#### onResult\n\nFunction called when a specific benchmark has finished running.\n\n```javascript\nonResult: (result: Benchee.Result) =\u003e void;\n```\n\n#### type\n\nThe type of benchmark to perform. _(defaults to `adaptive`)_\n\nValid values:\n\n- `adaptive` =\u003e number of iterations performed is based on an exponential algorithm driven by the `minTime`\n- `fixed` =\u003e number of iterations performed is based directly on `minIterations`\n\n## Support\n\n#### Browser\n\n- Chrome (33+)\n- Edge (all)\n- Firefox (29+)\n- Opera (20+)\n- Safari (7.1+)\n\n**NOTE**: If a `Promise` polyfill is provided, then older versions / unlisted browsers should be supported as well (notably IE11).\n\n#### Node\n\n- 6+\n\n## Development\n\nStandard stuff, clone the repo and `npm install` dependencies. The npm scripts available:\n\n- `build` =\u003e run rollup to build the distributed files in `dist`\n- `clean` =\u003e run `rimraf` on the `dist` folder\n- `dev` =\u003e run webpack dev server to run example app (playground!)\n- `dist` =\u003e runs `clean`, `build`, and `build:types`\n- `lint` =\u003e runs TSLint against all files in the `src` folder\n- `lint:fix` =\u003e runs `lint`, fixing any errors if possible\n- `prepublish` =\u003e runs `prepublish:compile`\n- `prepublish:compile` =\u003e run `lint`, `test:coverage`, and `dist`\n- `test` =\u003e run Jest, testing functions with `NODE_ENV=test`\n- `test:coverage` =\u003e run `test` but with code coverage output\n- `test:watch` =\u003e run `test`, but with persistent watcher\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanttheidea%2Fbenchee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplanttheidea%2Fbenchee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanttheidea%2Fbenchee/lists"}