github.com/zacg/go.matrix@v0.0.0-20140618230539-53ddaf7b8198/densebench_test.go (about) 1 package matrix 2 3 import ( 4 "fmt" 5 "testing" 6 "time" 7 ) 8 9 func BenchmarkTransposeTimes(b *testing.B) { 10 fmt.Println("benchmark") 11 for s := 25; s <= 100; s += 25 { 12 w, h := s/2, s*2 13 14 A := Normals(h, w) 15 B := Normals(w, h) 16 17 var times [2]float64 18 19 const Count = 500 20 21 MaxProcs = 1 22 WhichSyncMethod = 1 23 start := time.Now() 24 for i := 0; i < Count; i++ { 25 A.Times(B) 26 } 27 end := time.Now() 28 duration := end.Sub(start) 29 times[0] = float64(duration) / 1e9 30 31 WhichSyncMethod = 2 32 start = time.Now() 33 for i := 0; i < Count; i++ { 34 A.Times(B) 35 } 36 end = time.Now() 37 duration = end.Sub(start) 38 times[1] = float64(duration) / 1e9 39 fmt.Printf("%d: %.2f\n", h, times[1]/times[0]) 40 } 41 }