comfy-bench
v0.0.0
Published
Easy benchmarking
Downloads
2
Readme
comfy-bench
Easy benchmarking
Features:
- Very easy to use
- Gives pretty accurate numbers
- Hit ctl-c to interrupt and get quick results
- Works with very fast and very slow operations
- Works with sync and async operations
Example: readfile.js
import * as bench from 'comfy-bench'
import fsprom from 'fs/promises'
bench.add('read /etc/hostname', () => {
return fsprom.readFile('/etc/hostname')
})
bench.run()
output:
╔════════════════════╤═════════╤═══════╤═════════╗
║ Operation │ ops/sec │ Range │ usec/op ║
╟────────────────────┼─────────┼───────┼─────────╢
║ read /etc/hostname │ 17,506 │ ±2% │ 57 ║
╚════════════════════╧═════════╧═══════╧═════════╝
Example: system.js
import * as bench from 'comfy-bench'
bench.addSystemBenchmarks()
bench.run()
output:
Discarding best and worst samples, since we have 5 or more
╔════════════════════════════════════╤════════════╤═══════╤═════════╗
║ Operation │ ops/sec │ Range │ usec/op ║
╟────────────────────────────────────┼────────────┼───────┼─────────╢
║ function call │ 71,710,658 │ ±4% │ 0 ║
║ async function call │ 9,908,368 │ ±1% │ 0 ║
║ Date.now() │ 14,884,354 │ ±1% │ 0 ║
║ readdir /etc │ 4,053 │ ±1% │ 247 ║
║ read /etc/hostname │ 16,755 │ ±1% │ 60 ║
║ read 1 bytes from /etc/hostname │ 72,555 │ ±2% │ 14 ║
║ read 1024 bytes from /etc/hostname │ 73,665 │ ±1% │ 14 ║
║ read 16 bytes from /dev/urandom │ 65,780 │ ±2% │ 15 ║
║ read 8192 bytes from /dev/urandom │ 5,341 │ ±7% │ 187 ║
║ read 16 bytes from /dev/zero │ 75,093 │ ±1% │ 13 ║
║ read 8192 bytes from /dev/zero │ 70,731 │ ±1% │ 14 ║
╚════════════════════════════════════╧════════════╧═══════╧═════════╝