https://github.com/trapcodeio/benchmark
My Personal Benchmark kit
https://github.com/trapcodeio/benchmark
benchmark javascript node
Last synced: 9 months ago
JSON representation
My Personal Benchmark kit
- Host: GitHub
- URL: https://github.com/trapcodeio/benchmark
- Owner: trapcodeio
- Created: 2022-06-08T11:13:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-08T16:04:12.000Z (over 3 years ago)
- Last Synced: 2025-03-20T05:34:53.557Z (9 months ago)
- Topics: benchmark, javascript, node
- Language: TypeScript
- Homepage:
- Size: 6.84 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# My Personal Benchmark Kit
This packages only provides semantic helper functions for the original [Benchmark](https://npmjs.com/package/benchmark)
## Installation
```sh
npm i @trapcode/benchmark
# OR
yarn add @trapcode/benchmark
```
## Functions
List of functions available in this package.
- [benchmarkFunctions](#benchmarkfunctions)
### benchmarkFunctions
This function benchmarks an array/record of functions given to it.
#### Syntax
```javascript
import {benchmarkFunctions} from "@trapcode/benchmark"
benchmarkFunctions(FunctionsArray, options)
benchmarkFunctions(FunctionsObject, options)
benchmarkFunctions(Name, FunctionsArray | FunctionsObject, options)
```
#### Example
```javascript
import {benchmarkFunctions} from "@trapcode/benchmark"
function One() {
return 1 + 1;
}
function Two() {
// run one 100 times
let i = 100;
while (--i) One();
}
function Three() {
// run two 100 times
let i = 100;
while (--i) Two();
}
// An array of functions
benchmarkFunctions([One, Two, Three]).run();
// Or an object of functions.
benchmarkFunctions({ One, Two, Three }).run();
```
Result
```js
One x 894,565,407 ops/sec ±1.12% (84 runs sampled)
Two x 16,723,630 ops/sec ±0.89% (90 runs sampled)
Three x 190,309 ops/sec ±0.46% (95 runs sampled)
Fastest is [One]
```