Skip to content

Instantly share code, notes, and snippets.

@arsatiki
Created March 13, 2012 07:40
Show Gist options
  • Save arsatiki/2027462 to your computer and use it in GitHub Desktop.
Save arsatiki/2027462 to your computer and use it in GitHub Desktop.
Benchmark 0 ns
package hagh
import (
"testing"
"rand"
"time"
)
func BenchmarkMultiplication(b *testing.B) {
b.StopTimer()
d := make([]float64, 1 << 20)
o := make([]float64, 1 << 20)
for k := 0; k < len(d); k++ {
d[k] = rand.Float64()
}
b.StartTimer()
time.Sleep(100)
for k := 0; k < 20; k++ {
for i := 0; i < len(d) - 1; i += 2 {
o[i] = d[i] + d[i+1]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment