{"id":17241971,"url":"https://github.com/mtkennerly/kelonio","last_synced_at":"2026-02-28T06:56:42.915Z","repository":{"id":41472507,"uuid":"220686876","full_name":"mtkennerly/kelonio","owner":"mtkennerly","description":"Performance testing library for Node.js, written in TypeScript","archived":false,"fork":false,"pushed_at":"2024-03-16T14:05:36.000Z","size":1609,"stargazers_count":54,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-10T07:12:40.931Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://mtkennerly.github.io/kelonio","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/mtkennerly.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2019-11-09T18:39:55.000Z","updated_at":"2024-09-19T19:03:50.000Z","dependencies_parsed_at":"2024-06-18T18:28:34.634Z","dependency_job_id":"9e07177c-0ee4-47f1-8b4c-e133d5049582","html_url":"https://github.com/mtkennerly/kelonio","commit_stats":{"total_commits":53,"total_committers":5,"mean_commits":10.6,"dds":0.3207547169811321,"last_synced_commit":"6429ad04eefa28201f40a61e7b0bbc8755d8c592"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtkennerly%2Fkelonio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtkennerly%2Fkelonio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtkennerly%2Fkelonio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtkennerly%2Fkelonio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mtkennerly","download_url":"https://codeload.github.com/mtkennerly/kelonio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230507051,"owners_count":18236944,"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-15T06:11:55.510Z","updated_at":"2026-02-28T06:56:37.864Z","avatar_url":"https://github.com/mtkennerly.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kelonio\nKelonio is a performance testing library for Node.js, written in TypeScript.\nWhereas many similar projects are test frameworks in and of themselves,\nKelonio is fundamentally a **library** and therefore aims to integrate\nwith existing test frameworks seamlessly instead of reinventing the wheel.\nYou can use it inside of your existing tests from frameworks such as Jest and Mocha\n(along with any loaders like [ts-jest](https://www.npmjs.com/package/ts-jest)),\nand you can use it in the console and scripts as well.\n\nKelonio also works in the browser (as long as you use a tool like\n[Webpack](https://www.npmjs.com/package/webpack) or\n[Browserify](https://www.npmjs.com/package/browserify)),\nand it comes with built-in reporters for the following test frameworks\nwithout any direct dependency on them:\n\n* [Jest](https://www.npmjs.com/package/jest)\n* [Mocha](https://www.npmjs.com/package/mocha)\n* [Karma](https://www.npmjs.com/package/karma)\n\n## Usage\nFull API documentation:\n[https://mtkennerly.github.io/kelonio/modules](https://mtkennerly.github.io/kelonio/modules)\n\nFor simple, one-off checks, like in the console or a script, use the `measure` function:\n\n```typescript\nimport { measure } from \"kelonio\";\nimport axios from \"axios\";\n\nmeasure(() =\u003e axios.get(\"http://www.httpbin.org/get\"))\n    .then(measurement =\u003e console.log(`Mean: ${measurement.mean} ms`));\n```\n\nBy default, the check is repeated 100 times, but you can customize this.\nIf you measure a function that returns a promise,\nKelonio will automatically measure the time until it's resolved as well.\nThe resulting `measurement` exposes various stats,\nlike mean time, maximum time, and standard deviation.\n\nFor aggregating results from multiple measurements,\ncreate a `Benchmark` and use its `record` method to store the state:\n\n```typescript\nimport { Benchmark, Criteria } from \"kelonio\";\n\nconst benchmark = new Benchmark();\nawait benchmark.record(\"RegExp#test\", () =\u003e /o/.test(\"Hello World\"));\nawait benchmark.record(\"String#indexOf\", () =\u003e \"Hello World!\".indexOf(\"o\") \u003e -1);\n\nconst fastest = benchmark.find(Criteria.Fastest);\nconsole.log(`Fastest: ${fastest?.description} with mean ${fastest?.mean} ms`);\n// Fastest: String#indexOf with mean 0.004199049999999999 ms\n```\n\nFor aggregating results inside of a test framework,\nuse the default `benchmark` instance and its `record` method.\nClick to expand an example:\n\n\u003cdetails\u003e\n  \u003csummary\u003eExample: Jest\u003c/summary\u003e\n  \u003cdiv style=\"padding-left: 5px; border-left: 1px solid black;\"\u003e\n\n  Jest doesn't currently expose a way to get each individual test's name while running,\n  so you have to provide a description to `record()`.\n\n  Tests:\n\n  ```typescript\n  import { benchmark } from \"kelonio\";\n  import axios from \"axios\";\n\n  describe(\"An HTTP client\", () =\u003e {\n      it(\"can send GET requests\", async () =\u003e {\n          await benchmark.record(\n              [\"HTTP client\", \"GET\"],\n              () =\u003e axios.get(\"http://www.httpbin.org/get\")\n          );\n      }, 30_000);\n\n      it(\"can send POST requests\", async () =\u003e {\n          await benchmark.record(\n              [\"HTTP client\", \"POST\"],\n              () =\u003e axios.post(\"http://www.httpbin.org/post\"),\n              { iterations: 10, meanUnder: 10 },\n          );\n      }, 30_000);\n  });\n  ```\n\n  Output:\n\n  ```\n  FAIL ./index.test.ts (16.576s)\n    An HTTP client\n      √ can send GET requests (8332ms)\n      × can send POST requests (508ms)\n\n    ● An HTTP client › can send POST requests\n\n      Mean time of 49.43073600000001 ms exceeded threshold of 10 ms\n\n  Test Suites: 1 failed, 1 total\n  Tests:       1 failed, 1 passed, 2 total\n  Snapshots:   0 total\n  Time:        18.296s\n\n  - - - - - - - - - - - - - - - - - Performance - - - - - - - - - - - - - - - - -\n  HTTP client:\n    GET:\n      83.25152 ms (+/- 58.77542 ms) from 100 iterations\n    POST:\n      49.43074 ms (+/- 2.39217 ms) from 10 iterations\n  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n  ```\n\n  The first time on each line is the mean duration,\n  and the `+/-` time is the margin of error at a 95% confidence level.\n\n  \u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eExample: Mocha\u003c/summary\u003e\n  \u003cdiv style=\"padding-left: 5px; border-left: 1px solid black;\"\u003e\n\n  The Mocha reporter can automatically infer the descriptions from the test names,\n  but you're still free to pass additional descriptions to `record()`,\n  such as if one test performs several different measurements.\n\n  Tests:\n\n  ```typescript\n  import { benchmark } from \"kelonio\";\n  import axios from \"axios\";\n\n  describe(\"An HTTP client\", () =\u003e {\n      it(\"can send GET requests\", async function (this: Mocha.Test) {\n          this.timeout(30_000);\n          await benchmark.record(() =\u003e axios.get(\"http://www.httpbin.org/get\"));\n      });\n\n      it(\"can send POST requests\", async function (this: Mocha.Test) {\n          this.timeout(30_000);\n          await benchmark.record(\n              () =\u003e axios.post(\"http://www.httpbin.org/post\"),\n              { iterations: 10, meanUnder: 10 },\n          );\n      });\n  });\n  ```\n\n  Output:\n\n  ```\n    An HTTP client\n      √ can send GET requests\n      1) can send POST requests\n\n\n    1 passing (8332ms)\n    1 failing\n\n    1) An HTTP client\n        can send POST requests:\n      Error: Mean time of 49.43073600000001 ms exceeded threshold of 10 ms\n\n\n  - - - - - - - - - - - - - - - - - Performance - - - - - - - - - - - - - - - - -\n  An HTTP client:\n    can send GET requests:\n      83.25152 ms (+/- 58.77542 ms) from 100 iterations\n    can send POST requests:\n      49.43074 ms (+/- 2.39217 ms) from 10 iterations\n  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n  ```\n\n  The first time on each line is the mean duration,\n  and the `+/-` time is the margin of error at a 95% confidence level.\n\n  \u003c/div\u003e\n\u003c/details\u003e\n\nRefer to the `examples` folder for sample projects\nthat integrate Kelonio with different test frameworks.\n\n## Versioning\nThis project uses [Semantic Versioning](https://semver.org). Public API:\n\n* All items that can be imported `from \"kelonio\"` and their public attributes.\n* The location of reporter modules:\n  * `node_modules/kelonio/out/plugin/jestReporter.js`.\n    * `node_modules/kelonio/out/plugin/jestReporterSetup.js`.\n  * `node_modules/kelonio/out/plugin/karmaReporter.js`.\n    * `node_modules/kelonio/out/plugin/karmaReporterSetup.js`.\n  * `node_modules/kelonio/out/plugin/mochaReporter.js`.\n\n## Comparison with other tools\n* [Benchmark](https://www.npmjs.com/package/benchmark):\n  * Requires defining tests in its own framework.\n  * Doesn't provide a default report format,\n    so you have to write your own reporting in callbacks.\n  * Callbacks must be classic `function () {}` style because they need access to `this`,\n    which is not accounted for by\n    [@types/benchmark](https://www.npmjs.com/package/@types/benchmark).\n* [Nanobench](https://www.npmjs.com/package/nanobench):\n  * Requires defining tests in its own framework.\n  * The CLI can only handle JavaScript code, so in a TypeScript project,\n    you either have to compile the tests in addition to the main source\n    or you have to use `ts-node` (which appears to degrade the performance results).\n  * No typings available for TypeScript.\n* [Matcha](https://www.npmjs.com/package/matcha):\n  * Requires defining tests in its own framework.\n  * The CLI can only handle JavaScript code, so in a TypeScript project,\n    you either have to compile the tests instead of just the main source\n    or you have to use `ts-node` (which appears to degrade the performance results).\n  * No typings available for TypeScript.\n  * Depends on [Electron](https://www.npmjs.com/package/electron).\n\n## Development\nPlease refer to [CONTRIBUTING.md](./CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtkennerly%2Fkelonio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmtkennerly%2Fkelonio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtkennerly%2Fkelonio/lists"}