Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/felixge/benchmore
https://github.com/felixge/benchmore
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/felixge/benchmore
- Owner: felixge
- License: mit
- Created: 2022-02-05T19:42:05.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-19T15:02:22.000Z (almost 3 years ago)
- Last Synced: 2024-10-11T15:18:54.370Z (2 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 28
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# benchmore
This package allows you to report On-CPU Time in addition to the wall time
measured by Go's builtin benchmarking framework. Example:```go
import "github.com/felixge/benchmore"func BenchmarkAdd(b *testing.B) {
defer benchmore.ReportCPUTime(b)()for i := 0; i < b.N; i++ {
Add(i, i)
}
}func Add(a, b int) int {
return a + b
}
```
```
goos: darwin
goarch: amd64
pkg: github.com/felixge/benchmore
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkAdd-12 1000000000 0.2546 ns/op 0.2545 cpu-ns/op
PASS
ok github.com/felixge/benchmore 0.429s
```# More benchmore?
This package was created as a quick proof of concept response to a [tweet by @bwplotka](https://twitter.com/bwplotka/status/1490013375228698634).
In the future it could be extended to capture other metrics such as heap, rss, context switches, etc.
# License
MIT