-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRotationBenchmark.java
48 lines (36 loc) · 1.05 KB
/
RotationBenchmark.java
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
package com.aivean.raycasting2d;
import org.openjdk.jmh.annotations.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = 8, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 8, time = 2, timeUnit = TimeUnit.SECONDS)
@Fork(value = 1,
jvmArgs = {"-Xms2048m", "-XX:+UseSuperWord"}
)
@State(Scope.Thread)
public class RotationBenchmark {
@Param({/*"80", */"100"})
int size;
@Param({"CCW", "CW", "PI", "NO"})
String rotation;
Rotation rot;
int[][] arg;
int[][] res;
@Setup
public void setup() {
rot = Rotation.valueOf(rotation);
arg = new int[size][size];
res = new int[size][size];
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
arg[i][j] = ThreadLocalRandom.current().nextInt();
}
}
}
@Benchmark
public void benchRotation() {
rot.rotateInt(res, arg);
}
}