blob: f41e6a3570140cf71bbade054b7e5591b3ebc927 [file] [log] [blame]
Michael Chaten32c3a622012-04-21 13:24:41 +10001// Copyright 2012 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package runtime_test
6
7import (
8 "math/cmplx"
9 "testing"
10)
11
12var result complex128
13
14func BenchmarkComplex128DivNormal(b *testing.B) {
15 d := 15 + 2i
16 n := 32 + 3i
Shenghou Maaa45e522012-05-11 03:09:14 +080017 res := 0i
Michael Chaten32c3a622012-04-21 13:24:41 +100018 for i := 0; i < b.N; i++ {
Shenghou Maaa45e522012-05-11 03:09:14 +080019 n += 0.1i
20 res += n / d
Michael Chaten32c3a622012-04-21 13:24:41 +100021 }
Shenghou Maaa45e522012-05-11 03:09:14 +080022 result = res
Michael Chaten32c3a622012-04-21 13:24:41 +100023}
24
25func BenchmarkComplex128DivNisNaN(b *testing.B) {
26 d := cmplx.NaN()
27 n := 32 + 3i
Shenghou Maaa45e522012-05-11 03:09:14 +080028 res := 0i
Michael Chaten32c3a622012-04-21 13:24:41 +100029 for i := 0; i < b.N; i++ {
Shenghou Maaa45e522012-05-11 03:09:14 +080030 n += 0.1i
31 res += n / d
Michael Chaten32c3a622012-04-21 13:24:41 +100032 }
Shenghou Maaa45e522012-05-11 03:09:14 +080033 result = res
Michael Chaten32c3a622012-04-21 13:24:41 +100034}
35
36func BenchmarkComplex128DivDisNaN(b *testing.B) {
37 d := 15 + 2i
38 n := cmplx.NaN()
Shenghou Maaa45e522012-05-11 03:09:14 +080039 res := 0i
Michael Chaten32c3a622012-04-21 13:24:41 +100040 for i := 0; i < b.N; i++ {
Shenghou Maaa45e522012-05-11 03:09:14 +080041 d += 0.1i
42 res += n / d
Michael Chaten32c3a622012-04-21 13:24:41 +100043 }
Shenghou Maaa45e522012-05-11 03:09:14 +080044 result = res
Michael Chaten32c3a622012-04-21 13:24:41 +100045}
46
47func BenchmarkComplex128DivNisInf(b *testing.B) {
48 d := 15 + 2i
49 n := cmplx.Inf()
Shenghou Maaa45e522012-05-11 03:09:14 +080050 res := 0i
Michael Chaten32c3a622012-04-21 13:24:41 +100051 for i := 0; i < b.N; i++ {
Shenghou Maaa45e522012-05-11 03:09:14 +080052 d += 0.1i
53 res += n / d
Michael Chaten32c3a622012-04-21 13:24:41 +100054 }
Shenghou Maaa45e522012-05-11 03:09:14 +080055 result = res
Michael Chaten32c3a622012-04-21 13:24:41 +100056}
57
58func BenchmarkComplex128DivDisInf(b *testing.B) {
59 d := cmplx.Inf()
60 n := 32 + 3i
Shenghou Maaa45e522012-05-11 03:09:14 +080061 res := 0i
Michael Chaten32c3a622012-04-21 13:24:41 +100062 for i := 0; i < b.N; i++ {
Shenghou Maaa45e522012-05-11 03:09:14 +080063 n += 0.1i
64 res += n / d
Michael Chaten32c3a622012-04-21 13:24:41 +100065 }
Shenghou Maaa45e522012-05-11 03:09:14 +080066 result = res
Michael Chaten32c3a622012-04-21 13:24:41 +100067}