@@ -10,95 +10,84 @@ public class PerformanceMetrics {
1010 * Likely to be at least a little bit of an undercount,
1111 * given that the tournament module is timing a superset of JBWAPI's execution time.
1212 */
13- public PerformanceMetric totalFrameDuration ;
13+ PerformanceMetric totalFrameDuration ;
1414
1515 /**
1616 * Time spent copying game data from system pipe shared memory to a frame buffer.
1717 * Applicable only in asynchronous mode.
1818 */
19- public PerformanceMetric copyingToBuffer ;
19+ PerformanceMetric copyingToBuffer ;
2020
2121 /**
2222 * Time spent intentionally blocking on bot operation due to a full frame buffer.
2323 * Applicable only in asynchronous mode.
2424 */
25- public PerformanceMetric intentionallyBlocking ;
25+ PerformanceMetric intentionallyBlocking ;
2626
2727 /**
2828 * Number of frames backed up in the frame buffer, after enqueuing each frame (and not including the newest frame).
2929 * Applicable only in asynchronous mode.
3030 */
31- public PerformanceMetric frameBufferSize ;
31+ PerformanceMetric frameBufferSize ;
3232
3333 /**
3434 * Number of frames behind real-time the bot is at the time it handles events.
3535 * Applicable only in asynchronous mode.
3636 */
37- public PerformanceMetric framesBehind ;
37+ PerformanceMetric framesBehind ;
3838
3939 /**
4040 * Time spent applying bot commands to the live frame.
4141 */
42- public PerformanceMetric flushSideEffects ;
42+ PerformanceMetric flushSideEffects ;
4343
4444 /**
4545 * Time spent waiting for bot event handlers to complete for a single frame.
4646 */
47- public PerformanceMetric botResponse ;
47+ PerformanceMetric botResponse ;
4848
4949 /**
5050 * Time spent waiting for a response from BWAPI; is likely reflective of the performance of any opponent bots.
5151 */
52- public PerformanceMetric bwapiResponse ;
52+ PerformanceMetric bwapiResponse ;
5353
5454 /**
5555 * Time bot spends idle.
5656 * Applicable only in asynchronous mode.
5757 */
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 ;
7171
7272 private BWClientConfiguration configuration ;
7373
74- public PerformanceMetrics (BWClientConfiguration configuration ) {
74+ PerformanceMetrics (BWClientConfiguration configuration ) {
7575 this .configuration = configuration ;
7676 reset ();
7777 }
7878
7979 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 );
8482 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 );
9088 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 );
10291 }
10392
10493 @ Override
@@ -113,16 +102,7 @@ public String toString() {
113102 + "\n " + botResponse .toString ()
114103 + "\n " + bwapiResponse .toString ()
115104 + "\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 ();
127107 }
128108}
0 commit comments