summaryrefslogtreecommitdiff
path: root/internal/cpu/stresser_bench_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cpu/stresser_bench_test.go')
-rw-r--r--internal/cpu/stresser_bench_test.go114
1 files changed, 114 insertions, 0 deletions
diff --git a/internal/cpu/stresser_bench_test.go b/internal/cpu/stresser_bench_test.go
new file mode 100644
index 0000000..042b6f2
--- /dev/null
+++ b/internal/cpu/stresser_bench_test.go
@@ -0,0 +1,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)
+}