@@ -10,95 +10,84 @@ public class PerformanceMetrics {
10
10
* Likely to be at least a little bit of an undercount,
11
11
* given that the tournament module is timing a superset of JBWAPI's execution time.
12
12
*/
13
- public PerformanceMetric totalFrameDuration ;
13
+ PerformanceMetric totalFrameDuration ;
14
14
15
15
/**
16
16
* Time spent copying game data from system pipe shared memory to a frame buffer.
17
17
* Applicable only in asynchronous mode.
18
18
*/
19
- public PerformanceMetric copyingToBuffer ;
19
+ PerformanceMetric copyingToBuffer ;
20
20
21
21
/**
22
22
* Time spent intentionally blocking on bot operation due to a full frame buffer.
23
23
* Applicable only in asynchronous mode.
24
24
*/
25
- public PerformanceMetric intentionallyBlocking ;
25
+ PerformanceMetric intentionallyBlocking ;
26
26
27
27
/**
28
28
* Number of frames backed up in the frame buffer, after enqueuing each frame (and not including the newest frame).
29
29
* Applicable only in asynchronous mode.
30
30
*/
31
- public PerformanceMetric frameBufferSize ;
31
+ PerformanceMetric frameBufferSize ;
32
32
33
33
/**
34
34
* Number of frames behind real-time the bot is at the time it handles events.
35
35
* Applicable only in asynchronous mode.
36
36
*/
37
- public PerformanceMetric framesBehind ;
37
+ PerformanceMetric framesBehind ;
38
38
39
39
/**
40
40
* Time spent applying bot commands to the live frame.
41
41
*/
42
- public PerformanceMetric flushSideEffects ;
42
+ PerformanceMetric flushSideEffects ;
43
43
44
44
/**
45
45
* Time spent waiting for bot event handlers to complete for a single frame.
46
46
*/
47
- public PerformanceMetric botResponse ;
47
+ PerformanceMetric botResponse ;
48
48
49
49
/**
50
50
* Time spent waiting for a response from BWAPI; is likely reflective of the performance of any opponent bots.
51
51
*/
52
- public PerformanceMetric bwapiResponse ;
52
+ PerformanceMetric bwapiResponse ;
53
53
54
54
/**
55
55
* Time bot spends idle.
56
56
* Applicable only in asynchronous mode.
57
57
*/
58
- public PerformanceMetric botIdle ;
59
-
60
- public PerformanceMetric frameDuration5 ;
61
- public PerformanceMetric frameDuration10 ;
62
- public PerformanceMetric frameDuration15 ;
63
- public PerformanceMetric frameDuration20 ;
64
- public PerformanceMetric frameDuration25 ;
65
- public PerformanceMetric frameDuration30 ;
66
- public PerformanceMetric frameDuration35 ;
67
- public PerformanceMetric frameDuration40 ;
68
- public PerformanceMetric frameDuration45 ;
69
- public PerformanceMetric frameDuration50 ;
70
- public PerformanceMetric frameDuration55 ;
58
+ PerformanceMetric botIdle ;
59
+
60
+ /**
61
+ * Time the main thread spends idle, waiting for the bot to finish processing frames.
62
+ * Applicable only in asynchronous mode.
63
+ */
64
+ PerformanceMetric clientIdle ;
65
+
66
+ /**
67
+ * Time the main thread spends oversleeping its timeout target, potentially causing overtime frames.
68
+ * Applicable only in asynchronous mode.
69
+ */
70
+ PerformanceMetric excessSleep ;
71
71
72
72
private BWClientConfiguration configuration ;
73
73
74
- public PerformanceMetrics (BWClientConfiguration configuration ) {
74
+ PerformanceMetrics (BWClientConfiguration configuration ) {
75
75
this .configuration = configuration ;
76
76
reset ();
77
77
}
78
78
79
79
void reset () {
80
- final int sideEffectsBufferMs = 1 ;
81
- final int realTimeFrameMs = 42 ;
82
- totalFrameDuration = new PerformanceMetric ("JBWAPI frame duration" , configuration .maxFrameDurationMs + 5 );
83
- copyingToBuffer = new PerformanceMetric ("Time copying to buffer" , configuration .maxFrameDurationMs + 5 );
80
+ totalFrameDuration = new PerformanceMetric ("JBWAPI frame duration" , 5 , 10 , 15 , 20 , 25 , 30 , 35 , 40 , 45 , 50 , 55 , 85 );
81
+ copyingToBuffer = new PerformanceMetric ("Time copying to buffer" , 5 , 10 , 15 , 20 , 25 , 30 );
84
82
intentionallyBlocking = new PerformanceMetric ("Blocking with full buffer" , 0 );
85
- frameBufferSize = new PerformanceMetric ("Frames buffered" , 0 );
86
- framesBehind = new PerformanceMetric ("Frames behind real-time" , 0 );
87
- flushSideEffects = new PerformanceMetric ("Flushing side effects" , sideEffectsBufferMs );
88
- botResponse = new PerformanceMetric ("Bot event handlers" , configuration . maxFrameDurationMs );
89
- bwapiResponse = new PerformanceMetric ("Responses from BWAPI" , realTimeFrameMs );
83
+ frameBufferSize = new PerformanceMetric ("Frames buffered" , 0 , 1 );
84
+ framesBehind = new PerformanceMetric ("Frames behind real-time" , 0 , 1 );
85
+ flushSideEffects = new PerformanceMetric ("Flushing side effects" , 1 , 3 , 5 );
86
+ botResponse = new PerformanceMetric ("Bot event handlers" , 5 , 10 , 15 , 20 , 25 , 30 , 35 , 40 , 45 , 50 , 55 , 85 );
87
+ bwapiResponse = new PerformanceMetric ("Responses from BWAPI" , 5 , 10 , 15 , 20 , 25 , 30 , 35 , 40 , 45 , 50 , 55 , 85 );
90
88
botIdle = new PerformanceMetric ("Bot idle" , Long .MAX_VALUE );
91
- frameDuration5 = new PerformanceMetric ("JBWAPI frame @ 5ms" , 5 );
92
- frameDuration10 = new PerformanceMetric ("JBWAPI frame @ 10ms" , 10 );
93
- frameDuration15 = new PerformanceMetric ("JBWAPI frame @ 15ms" , 15 );
94
- frameDuration20 = new PerformanceMetric ("JBWAPI frame @ 20ms" , 20 );
95
- frameDuration25 = new PerformanceMetric ("JBWAPI frame @ 25ms" , 25 );
96
- frameDuration30 = new PerformanceMetric ("JBWAPI frame @ 30ms" , 30 );
97
- frameDuration35 = new PerformanceMetric ("JBWAPI frame @ 35ms" , 35 );
98
- frameDuration40 = new PerformanceMetric ("JBWAPI frame @ 40ms" , 40 );
99
- frameDuration45 = new PerformanceMetric ("JBWAPI frame @ 45ms" , 45 );
100
- frameDuration50 = new PerformanceMetric ("JBWAPI frame @ 50ms" , 50 );
101
- frameDuration55 = new PerformanceMetric ("JBWAPI frame @ 55ms" , 55 );
89
+ clientIdle = new PerformanceMetric ("Client idling" , configuration .maxFrameDurationMs );
90
+ excessSleep = new PerformanceMetric ("Excess sleep" , 1 , 5 , 10 , 15 , 20 , 25 , 30 , 35 , 40 , 45 , 50 , 55 , 85 );
102
91
}
103
92
104
93
@ Override
@@ -113,16 +102,7 @@ public String toString() {
113
102
+ "\n " + botResponse .toString ()
114
103
+ "\n " + bwapiResponse .toString ()
115
104
+ "\n " + botIdle .toString ()
116
- + "\n " + frameDuration5 .toString ()
117
- + "\n " + frameDuration10 .toString ()
118
- + "\n " + frameDuration15 .toString ()
119
- + "\n " + frameDuration20 .toString ()
120
- + "\n " + frameDuration25 .toString ()
121
- + "\n " + frameDuration30 .toString ()
122
- + "\n " + frameDuration35 .toString ()
123
- + "\n " + frameDuration40 .toString ()
124
- + "\n " + frameDuration45 .toString ()
125
- + "\n " + frameDuration50 .toString ()
126
- + "\n " + frameDuration55 .toString ();
105
+ + "\n " + clientIdle .toString ()
106
+ + "\n " + excessSleep .toString ();
127
107
}
128
108
}
0 commit comments