2012-04-20 21:24:41 -06:00
|
|
|
// Copyright 2012 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package runtime_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/cmplx"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var result complex128
|
|
|
|
|
|
|
|
func BenchmarkComplex128DivNormal(b *testing.B) {
|
|
|
|
d := 15 + 2i
|
|
|
|
n := 32 + 3i
|
2012-05-10 13:09:14 -06:00
|
|
|
res := 0i
|
2012-04-20 21:24:41 -06:00
|
|
|
for i := 0; i < b.N; i++ {
|
2012-05-10 13:09:14 -06:00
|
|
|
n += 0.1i
|
|
|
|
res += n / d
|
2012-04-20 21:24:41 -06:00
|
|
|
}
|
2012-05-10 13:09:14 -06:00
|
|
|
result = res
|
2012-04-20 21:24:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkComplex128DivNisNaN(b *testing.B) {
|
|
|
|
d := cmplx.NaN()
|
|
|
|
n := 32 + 3i
|
2012-05-10 13:09:14 -06:00
|
|
|
res := 0i
|
2012-04-20 21:24:41 -06:00
|
|
|
for i := 0; i < b.N; i++ {
|
2012-05-10 13:09:14 -06:00
|
|
|
n += 0.1i
|
|
|
|
res += n / d
|
2012-04-20 21:24:41 -06:00
|
|
|
}
|
2012-05-10 13:09:14 -06:00
|
|
|
result = res
|
2012-04-20 21:24:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkComplex128DivDisNaN(b *testing.B) {
|
|
|
|
d := 15 + 2i
|
|
|
|
n := cmplx.NaN()
|
2012-05-10 13:09:14 -06:00
|
|
|
res := 0i
|
2012-04-20 21:24:41 -06:00
|
|
|
for i := 0; i < b.N; i++ {
|
2012-05-10 13:09:14 -06:00
|
|
|
d += 0.1i
|
|
|
|
res += n / d
|
2012-04-20 21:24:41 -06:00
|
|
|
}
|
2012-05-10 13:09:14 -06:00
|
|
|
result = res
|
2012-04-20 21:24:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkComplex128DivNisInf(b *testing.B) {
|
|
|
|
d := 15 + 2i
|
|
|
|
n := cmplx.Inf()
|
2012-05-10 13:09:14 -06:00
|
|
|
res := 0i
|
2012-04-20 21:24:41 -06:00
|
|
|
for i := 0; i < b.N; i++ {
|
2012-05-10 13:09:14 -06:00
|
|
|
d += 0.1i
|
|
|
|
res += n / d
|
2012-04-20 21:24:41 -06:00
|
|
|
}
|
2012-05-10 13:09:14 -06:00
|
|
|
result = res
|
2012-04-20 21:24:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkComplex128DivDisInf(b *testing.B) {
|
|
|
|
d := cmplx.Inf()
|
|
|
|
n := 32 + 3i
|
2012-05-10 13:09:14 -06:00
|
|
|
res := 0i
|
2012-04-20 21:24:41 -06:00
|
|
|
for i := 0; i < b.N; i++ {
|
2012-05-10 13:09:14 -06:00
|
|
|
n += 0.1i
|
|
|
|
res += n / d
|
2012-04-20 21:24:41 -06:00
|
|
|
}
|
2012-05-10 13:09:14 -06:00
|
|
|
result = res
|
2012-04-20 21:24:41 -06:00
|
|
|
}
|