Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1637)

Unified Diff: test/bench/go/divmul_test.go

Issue 6819087: code review 6819087: test/bench/go: new package (Closed)
Patch Set: diff -r a53601cd4e63 https://code.google.com/p/go Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/bench/go/asop_test.go ('k') | test/bench/go/doc.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/bench/go/divmul_test.go
===================================================================
rename from src/pkg/runtime/vlop_arm_test.go
rename to test/bench/go/divmul_test.go
--- a/src/pkg/runtime/vlop_arm_test.go
+++ b/test/bench/go/divmul_test.go
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package runtime_test
+package bench
import "testing"
-// arm soft division benchmarks adapted from
+// division benchmarks adapted from
// http://ridiculousfish.com/files/division_benchmarks.tar.gz
const numeratorsSize = 1 << 21
@@ -33,11 +33,16 @@
return numerators
}
+// arm softdiv benchmarks
+
+var u uint32
+
func bmUint32Div(divisor uint32, b *testing.B) {
var sum uint32
for i := 0; i < b.N; i++ {
sum += numerators[i&(numeratorsSize-1)] / divisor
}
+ u += sum
}
func BenchmarkUint32Div7(b *testing.B) { bmUint32Div(7, b) }
@@ -56,6 +61,7 @@
for i := 0; i < b.N; i++ {
sum += numerators[i&(numeratorsSize-1)] % divisor
}
+ u += sum
}
func BenchmarkUint32Mod7(b *testing.B) { bmUint32Mod(7, b) }
@@ -68,3 +74,111 @@
func BenchmarkUint32Mod52513(b *testing.B) { bmUint32Mod(52513, b) }
func BenchmarkUint32Mod60978747(b *testing.B) { bmUint32Mod(60978747, b) }
func BenchmarkUint32Mod106956295(b *testing.B) { bmUint32Mod(106956295, b) }
+
+func BenchmarkDiv1(b *testing.B) {
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v /= 1
+ }
+ x += v
+}
+
+func BenchmarkDiv2(b *testing.B) {
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v /= 2
+ }
+ x += v
+}
+
+func BenchmarkDiv4(b *testing.B) {
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v /= 4
+ }
+ x += v
+}
+
+func BenchmarkDiv10(b *testing.B) {
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v /= 10
+ }
+ x += v
+}
+
+func BenchmarkMod1(b *testing.B) {
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v %= 1
+ }
+ x += v
+}
+
+func BenchmarkMod2(b *testing.B) {
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v %= 2
+ }
+ x += v
+}
+
+func BenchmarkMod4(b *testing.B) {
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v %= 4
+ }
+ x += v
+}
+
+func BenchmarkMod10(b *testing.B) {
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v %= 10
+ }
+ x += v
+}
+
+func BenchmarkMul1(b *testing.B) {
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v *= 1
+ }
+ x += v
+}
+
+func BenchmarkMul2(b *testing.B) {
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v *= 2
+ }
+ x += v
+}
+
+func BenchmarkMul4(b *testing.B) {
r 2012/11/09 22:41:56 let's be pedantic and name these more accurately
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v *= 4
+ }
+ x += v
+}
+
+// issue 2671. The compiler should be produce
+// the identical code for Mul10 into MagicMul10
+func BenchmarkMul10(b *testing.B) {
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v *= 10
+ }
+ x += v
+}
+
+func BenchmarkMagicMul10(b *testing.B) {
bradfitz 2012/11/11 23:48:02 if v == 5, the result of this is 42, not 50.
+ v := 0
+ for i := 0; i < b.N; i++ {
+ v <<= 3
+ v++
+ v++
+ }
+ x += v
+}
« no previous file with comments | « test/bench/go/asop_test.go ('k') | test/bench/go/doc.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b