Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mobarski/nim-bench
Simple Benchmarking Library for Nim
https://github.com/mobarski/nim-bench
benchmarking nim nim-lang
Last synced: 18 days ago
JSON representation
Simple Benchmarking Library for Nim
- Host: GitHub
- URL: https://github.com/mobarski/nim-bench
- Owner: mobarski
- License: mit
- Created: 2023-11-16T23:23:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-28T18:14:55.000Z (12 months ago)
- Last Synced: 2024-11-03T09:42:05.345Z (2 months ago)
- Topics: benchmarking, nim, nim-lang
- Language: Nim
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bench
Simple benchmarking module for Nim.
## Example
```nim
import bench
import std/osvar b = new_bench("Test benchmark")
for i in 1..1000:
sleep(1)
b.done
b.show(item="run")
```**output:**
```
Test benchmark:
Time (avg ± stdev): 1.11 ms ± 0.14 µs
Time (min … max): 1.05 ms … 1.18 ms
Rate (avg): 899 runs/s
Runs: 1000
```## Installation
`nimble install https://github.com/mobarski/nim-bench`
## API
#### new_bench
`new_bench(label="Benchmark"): Bench`
Create new benchmark object with a given label.
#### done
`done(self: var Bench, items=1) `
Register successful run, which processed some items.
#### show
`show(self: Bench, item="item", skip=0)`
Show statistics. You can skip some initial runs and define the item label.
## Similar projects
- [stopwatch](https://gitlab.com/define-private-public/stopwatch)
- [timeit](https://github.com/ringabout/timeit)
- [criterion](https://github.com/disruptek/criterion)
- [nimbench](https://github.com/ivankoster/nimbench)