Source file
src/runtime/complex_test.go
1
2
3
4
5 package runtime_test
6
7 import (
8 "math/cmplx"
9 "testing"
10 )
11
12 var result complex128
13
14 func BenchmarkComplex128DivNormal(b *testing.B) {
15 d := 15 + 2i
16 n := 32 + 3i
17 res := 0i
18 for i := 0; i < b.N; i++ {
19 n += 0.1i
20 res += n / d
21 }
22 result = res
23 }
24
25 func BenchmarkComplex128DivNisNaN(b *testing.B) {
26 d := cmplx.NaN()
27 n := 32 + 3i
28 res := 0i
29 for i := 0; i < b.N; i++ {
30 n += 0.1i
31 res += n / d
32 }
33 result = res
34 }
35
36 func BenchmarkComplex128DivDisNaN(b *testing.B) {
37 d := 15 + 2i
38 n := cmplx.NaN()
39 res := 0i
40 for i := 0; i < b.N; i++ {
41 d += 0.1i
42 res += n / d
43 }
44 result = res
45 }
46
47 func BenchmarkComplex128DivNisInf(b *testing.B) {
48 d := 15 + 2i
49 n := cmplx.Inf()
50 res := 0i
51 for i := 0; i < b.N; i++ {
52 d += 0.1i
53 res += n / d
54 }
55 result = res
56 }
57
58 func BenchmarkComplex128DivDisInf(b *testing.B) {
59 d := cmplx.Inf()
60 n := 32 + 3i
61 res := 0i
62 for i := 0; i < b.N; i++ {
63 n += 0.1i
64 res += n / d
65 }
66 result = res
67 }
68
View as plain text