1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
package cpu
import (
"context"
"testing"
)
func benchmarkStress(b *testing.B, stressFunc func(context.Context, int), intensity int) {
b.Helper()
ctx := context.Background()
for i := 0; i < b.N; i++ {
stressFunc(ctx, intensity)
}
}
func BenchmarkStressPrime(b *testing.B) {
s := New(Config{
Mode: ModePrime,
Workers: 1,
IntensityMin: 100,
IntensityMax: 1000,
})
benchmarkStress(b, s.stressPrime, 100)
}
func BenchmarkStressMatrix(b *testing.B) {
s := New(Config{
Mode: ModeMatrix,
Workers: 1,
IntensityMin: 10,
IntensityMax: 50,
})
benchmarkStress(b, s.stressMatrix, 50)
}
func BenchmarkStressHash(b *testing.B) {
s := New(Config{
Mode: ModeHash,
Workers: 1,
IntensityMin: 100,
IntensityMax: 1000,
})
benchmarkStress(b, s.stressHash, 100)
}
func BenchmarkStressBitwise(b *testing.B) {
s := New(Config{
Mode: ModeBitwise,
Workers: 1,
IntensityMin: 100,
IntensityMax: 1000,
})
benchmarkStress(b, s.stressBitwise, 100)
}
func BenchmarkStressFloat(b *testing.B) {
s := New(Config{
Mode: ModeFloat,
Workers: 1,
IntensityMin: 100,
IntensityMax: 1000,
})
benchmarkStress(b, s.stressFloat, 100)
}
func BenchmarkStressRecurse(b *testing.B) {
s := New(Config{
Mode: ModeRecurse,
Workers: 1,
IntensityMin: 10,
IntensityMax: 30,
})
benchmarkStress(b, s.stressRecurse, 25)
}
func BenchmarkStressCompress(b *testing.B) {
s := New(Config{
Mode: ModeCompress,
Workers: 1,
IntensityMin: 100,
IntensityMax: 1000,
})
benchmarkStress(b, s.stressCompress, 100)
}
func BenchmarkStressEncrypt(b *testing.B) {
s := New(Config{
Mode: ModeEncrypt,
Workers: 1,
IntensityMin: 100,
IntensityMax: 1000,
})
benchmarkStress(b, s.stressEncrypt, 100)
}
func BenchmarkStressSort(b *testing.B) {
s := New(Config{
Mode: ModeSort,
Workers: 1,
IntensityMin: 100,
IntensityMax: 1000,
})
benchmarkStress(b, s.stressSort, 1000)
}
func BenchmarkStressBusy(b *testing.B) {
s := New(Config{
Mode: ModeBusy,
Workers: 1,
IntensityMin: 100,
IntensityMax: 1000,
})
benchmarkStress(b, s.stressBusy, 100)
}
|