benchmark
This is a small utility that supports:
- Benchmarks
async
functions (on top of simple synchronous functions).abort()
in order to, well, abort!- Defining multiple units to benchmark (
.add(name, function)
) - Defining prepare and teardown callbacks (
.add(name, { prepare, unit, teardown })
) - Decide how you want to present the results on your own
- Do a warmup run before running benchmarks for each unit (
.setWarmupTime(milliseconds)
) - Set up time for benchmarking each unit (
.setMaxUnitTime(milliseconds)
) - Set up how many runs to do for each unit, which is useful for detecting deviations and unstable behavior (
.setRunsPerUnit(runs)
) await benchmark.run(options)
for compatibility with modernawait
syntax or.then
/.catch
- There are JSDocs for everything, which should make intellisense much easier and stricter.
Installation:
npm i benchmark-util
Usage example:
async { const Benchmark = ; let bench = ; bench ; let results = await bench; let fastest = results0name; console;};
Contributing
I welcome contributions of any kind.
Me
- Hi! I am Daniel.
- danielgindi@gmail.com is my email address.
- That's all you need to know.
Help
If you want to buy me a beer, you are very welcome to Thanks :-)
License
All the code here is under MIT license. Which means you could do virtually anything with the code. I will appreciate it very much if you keep an attribution where appropriate.
The MIT License (MIT)
Copyright (c) 2013 Daniel Cohen Gindi (danielgindi@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.