Skip to content

Instantly share code, notes, and snippets.

@kayslay
Created December 19, 2019 00:50
Show Gist options
  • Save kayslay/548fdb720e5c5d5ccf37f5a5a5cf0068 to your computer and use it in GitHub Desktop.
Save kayslay/548fdb720e5c5d5ccf37f5a5a5cf0068 to your computer and use it in GitHub Desktop.
package main
import (
"runtime"
"testing"
)
// limit to a single processor
var _ = runtime.GOMAXPROCS(1)
func Benchmark_cpuExampleSequential(b *testing.B) {
for n := 0; n < b.N; n++ {
cpuExampleSequential()
}
}
func Benchmark_cpuExampleConcurrent(b *testing.B) {
for n := 0; n < b.N; n++ {
cpuExampleConcurrent()
}
}
func Benchmark_ioExampleSequential(b *testing.B) {
for n := 0; n < b.N; n++ {
ioExampleSequential()
}
}
func Benchmark_ioExampleConcurrent(b *testing.B) {
for n := 0; n < b.N; n++ {
ioExampleConcurrent()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment