summaryrefslogtreecommitdiff
path: root/Benchmarking code in Golang.md
diff options
context:
space:
mode:
Diffstat (limited to 'Benchmarking code in Golang.md')
-rw-r--r--Benchmarking code in Golang.md7
1 files changed, 3 insertions, 4 deletions
diff --git a/Benchmarking code in Golang.md b/Benchmarking code in Golang.md
index 22d180d..9bf9cfd 100644
--- a/Benchmarking code in Golang.md
+++ b/Benchmarking code in Golang.md
@@ -17,17 +17,16 @@ func main() {
Writing benchmarks. They look similar to tests:
```
-import testing
+import "testing"
func BenchmarkSome(b *testing.B) {
- for i := 0; i < b.N; i++ {
+ for b.Loop() {
Some()
}
}
```
-b.N is supplied by test driver and is dynamically changed depending on runtime.
-`go test -bench=<regex>`
+`go test -bench=<regex>` (thus `-bench=.` will run all tests)
This just benchmarks a function being called many times, comparative benchmarks can be written using a regular function being called from Benchmarks, something like so :
```