Descriptionmath: add fast path for Pow(x, 2)
linux/arm. ARMv5
benchmark old ns/op new ns/op delta
BenchmarkPowInt 59195 6505 -89.01%
BenchmarkPowFrac 153932 154104 +0.11%
BenchmarkPow10Pos 13941 14052 +0.80%
BenchmarkPow10Neg 17312 17283 -0.17%
linux/amd64. Core i5
benchmark old ns/op new ns/op delta
BenchmarkPowInt 60 6 -89.65%
BenchmarkPowFrac 127 128 +0.79%
BenchmarkPow10Pos 75 75 -0.13%
BenchmarkPow10Neg 80 79 -0.12%
darwin/386. Core Duo
benchmark old ns/op new ns/op delta
BenchmarkPowInt 191 14 -92.67%
BenchmarkPowFrac 348 348 +0.00%
BenchmarkPow10Pos 336 336 +0.00%
BenchmarkPow10Neg 324 325 +0.31%
Also reduces math/rand test runtime by 6x on linux/arm,Arm5.
Patch Set 1 #Patch Set 2 : diff -r 042bac4d6b6e https://code.google.com/p/go #MessagesTotal messages: 5
|