-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBenchmark.java
More file actions
67 lines (55 loc) · 1.87 KB
/
Copy pathBenchmark.java
File metadata and controls
67 lines (55 loc) · 1.87 KB
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
package fastghostmouse.benchmark;
import fastghostmouse.FastGhostMouse;
import org.openjdk.jmh.annotations.*;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class Benchmark {
private FastGhostMouse ghostMouse;
private BufferedImage cursorImg;
private float moveTarget = 100.0f;
@Setup(Level.Trial)
public void setup() {
ghostMouse = new FastGhostMouse();
ghostMouse.init(100, 100);
cursorImg = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = cursorImg.createGraphics();
g.setColor(new Color(255, 0, 0, 200));
g.fillOval(0, 0, 32, 32);
g.dispose();
}
@TearDown(Level.Trial)
public void tearDown() {
if (ghostMouse != null) {
ghostMouse.dispose();
}
}
@org.openjdk.jmh.annotations.Benchmark
public void benchmarkMoveToTarget() {
moveTarget = (moveTarget > 800.0f) ? 100.0f : moveTarget + 2.0f;
ghostMouse.moveTo(moveTarget, moveTarget);
}
@org.openjdk.jmh.annotations.Benchmark
public void benchmarkSetCursorPositionImmediate() {
ghostMouse.setCursorPositionImmediate(250, 250);
}
@org.openjdk.jmh.annotations.Benchmark
public void benchmarkSetTextOffset() {
ghostMouse.setTextOffset(15.0f, -25.0f);
}
@org.openjdk.jmh.annotations.Benchmark
public void benchmarkSetSmoothing() {
ghostMouse.setSmoothing(0.18f);
}
@org.openjdk.jmh.annotations.Benchmark
public void benchmarkUpdateCursorImage() {
ghostMouse.setCursorImage(cursorImg);
}
}