11# Kelonio
22Kelonio is a performance testing library for Node.js, written in TypeScript.
3- Whereas many similar projects are test frameworks in and of themselves, Kelonio
4- is fundamentally a ** library** and therefore aims to integrate with existing
5- test frameworks seamlessly instead of reinventing the wheel. You can use it
6- inside of your existing tests from frameworks such as Jest and Mocha (along
7- with any loaders like [ ts-jest] ( https://www.npmjs.com/package/ts-jest ) ),
3+ Whereas many similar projects are test frameworks in and of themselves,
4+ Kelonio is fundamentally a ** library** and therefore aims to integrate
5+ with existing test frameworks seamlessly instead of reinventing the wheel.
6+ You can use it inside of your existing tests from frameworks such as Jest and Mocha
7+ (along with any loaders like [ ts-jest] ( https://www.npmjs.com/package/ts-jest ) ),
88and you can use it in the console and scripts as well.
99
1010Kelonio also works in the browser (as long as you use a tool like
1111[ Webpack] ( https://www.npmjs.com/package/webpack ) or
1212[ Browserify] ( https://www.npmjs.com/package/browserify ) ),
13- and it comes with built-in reporters for the following test frameworks without
14- any direct dependency on them:
13+ and it comes with built-in reporters for the following test frameworks
14+ without any direct dependency on them:
1515
1616* [ Jest] ( https://www.npmjs.com/package/jest )
1717* [ Mocha] ( https://www.npmjs.com/package/mocha )
@@ -21,8 +21,7 @@ any direct dependency on them:
2121Full API documentation:
2222[ https://mtkennerly.github.io/kelonio/modules ] ( https://mtkennerly.github.io/kelonio/modules )
2323
24- For simple, one-off checks, like in the console or a script, use the ` measure `
25- function:
24+ For simple, one-off checks, like in the console or a script, use the ` measure ` function:
2625
2726``` typescript
2827import { measure } from " kelonio" ;
@@ -33,12 +32,13 @@ measure(() => axios.get("http://www.httpbin.org/get"))
3332```
3433
3534By default, the check is repeated 100 times, but you can customize this.
36- If you measure a function that returns a promise, Kelonio will automatically
37- measure the time until it's resolved as well. The resulting ` measurement `
38- exposes various stats, like mean time, maximum time, and standard deviation.
35+ If you measure a function that returns a promise,
36+ Kelonio will automatically measure the time until it's resolved as well.
37+ The resulting ` measurement ` exposes various stats,
38+ like mean time, maximum time, and standard deviation.
3939
40- For aggregating results from multiple measurements, create a ` Benchmark ` and
41- use its ` record ` method to store the state:
40+ For aggregating results from multiple measurements,
41+ create a ` Benchmark ` and use its ` record ` method to store the state:
4242
4343``` typescript
4444import { Benchmark , Criteria } from " kelonio" ;
@@ -52,15 +52,16 @@ console.log(`Fastest: ${fastest?.description} with mean ${fastest?.mean} ms`);
5252// Fastest: String#indexOf with mean 0.004199049999999999 ms
5353```
5454
55- For aggregating results inside of a test framework, use the default ` benchmark `
56- instance and its ` record ` method. Click to expand an example:
55+ For aggregating results inside of a test framework,
56+ use the default ` benchmark ` instance and its ` record ` method.
57+ Click to expand an example:
5758
5859<details >
5960 <summary >Example: Jest</summary >
6061 <div style =" padding-left : 5px ; border-left : 1px solid black ;" >
6162
62- Jest doesn't currently expose a way to get each individual test's name
63- while running, so you have to provide a description to ` record() ` .
63+ Jest doesn't currently expose a way to get each individual test's name while running,
64+ so you have to provide a description to ` record() ` .
6465
6566 Tests:
6667
@@ -112,8 +113,8 @@ instance and its `record` method. Click to expand an example:
112113 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
113114 ```
114115
115- The first time on each line is the mean duration, and the ` +/- ` time is
116- the margin of error at a 95% confidence level.
116+ The first time on each line is the mean duration,
117+ and the ` +/- ` time is the margin of error at a 95% confidence level.
117118
118119 </div >
119120</details >
@@ -122,8 +123,8 @@ instance and its `record` method. Click to expand an example:
122123 <summary >Example: Mocha</summary >
123124 <div style =" padding-left : 5px ; border-left : 1px solid black ;" >
124125
125- The Mocha reporter can automatically infer the descriptions from the test
126- names, but you're still free to pass additional descriptions to ` record() ` ,
126+ The Mocha reporter can automatically infer the descriptions from the test names,
127+ but you're still free to pass additional descriptions to ` record() ` ,
127128 such as if one test performs several different measurements.
128129
129130 Tests:
@@ -173,14 +174,14 @@ instance and its `record` method. Click to expand an example:
173174 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
174175 ```
175176
176- The first time on each line is the mean duration, and the ` +/- ` time is
177- the margin of error at a 95% confidence level.
177+ The first time on each line is the mean duration,
178+ and the ` +/- ` time is the margin of error at a 95% confidence level.
178179
179180 </div >
180181</details >
181182
182- Refer to the ` examples ` folder for sample projects that integrate Kelonio with
183- different test frameworks.
183+ Refer to the ` examples ` folder for sample projects
184+ that integrate Kelonio with different test frameworks.
184185
185186## Versioning
186187This project uses [ Semantic Versioning] ( https://semver.org ) . Public API:
@@ -196,10 +197,10 @@ This project uses [Semantic Versioning](https://semver.org). Public API:
196197## Comparison with other tools
197198* [ Benchmark] ( https://www.npmjs.com/package/benchmark ) :
198199 * Requires defining tests in its own framework.
199- * Doesn't provide a default report format, so you have to write your own
200- reporting in callbacks.
201- * Callbacks must be classic ` function () {} ` style because they need access
202- to ` this ` , which is not accounted for by
200+ * Doesn't provide a default report format,
201+ so you have to write your own reporting in callbacks.
202+ * Callbacks must be classic ` function () {} ` style because they need access to ` this ` ,
203+ which is not accounted for by
203204 [ @types/benchmark ] ( https://www.npmjs.com/package/@types/benchmark ) .
204205* [ Nanobench] ( https://www.npmjs.com/package/nanobench ) :
205206 * Requires defining tests in its own framework.
0 commit comments