@@ -11,6 +11,7 @@ import com.squareup.benchmarks.performance.complex.poetry.instrumentation.Render
11
11
import com.squareup.benchmarks.performance.complex.poetry.instrumentation.SimulatedPerfConfig
12
12
import com.squareup.benchmarks.performance.complex.poetry.robots.landscapeOrientation
13
13
import com.squareup.benchmarks.performance.complex.poetry.robots.openRavenAndNavigate
14
+ import com.squareup.benchmarks.performance.complex.poetry.robots.resetToRootPoetryList
14
15
import com.squareup.benchmarks.performance.complex.poetry.robots.waitForPoetry
15
16
import org.junit.Assert.fail
16
17
import org.junit.Before
@@ -38,16 +39,21 @@ class RenderPassTest {
38
39
@Before fun setup () {
39
40
context = ApplicationProvider .getApplicationContext()
40
41
PerformancePoetryActivity .installedInterceptor = renderPassCountingInterceptor
42
+
43
+ device.wakeUp()
44
+ device.pressHome()
45
+ device.waitForIdle()
46
+
47
+ // Do these in landscape so we have both the 'index' and the 'detail' showing.
48
+ device.landscapeOrientation()
41
49
}
42
50
43
51
@Test fun renderPassCounterComplexWithInitializingState () {
44
- // https://github.com/square/workflow-kotlin/issues/745
45
- // runRenderPassCounter(COMPLEX_INITIALIZING)
52
+ runRenderPassCounter(COMPLEX_INITIALIZING )
46
53
}
47
54
48
55
@Test fun renderPassCounterComplexNoInitializingState () {
49
- // https://github.com/square/workflow-kotlin/issues/745
50
- // runRenderPassCounter(COMPLEX_NO_INITIALIZING)
56
+ runRenderPassCounter(COMPLEX_NO_INITIALIZING )
51
57
}
52
58
53
59
private fun runRenderPassCounter (scenario : Scenario ) {
@@ -56,16 +62,17 @@ class RenderPassTest {
56
62
addFlags(Intent .FLAG_ACTIVITY_CLEAR_TASK )
57
63
putExtra(PERF_CONFIG_EXTRA , scenario.config)
58
64
}
59
- device.wakeUp()
60
- device.pressHome()
61
- // Do these in landscape so we have both the 'index' and the 'detail' showing.
62
- device.landscapeOrientation()
63
65
64
66
InstrumentationRegistry .getInstrumentation().context.startActivity(intent)
65
-
66
67
device.waitForPoetry()
67
68
device.waitForIdle()
68
69
70
+ // Go back to root list so this is deterministic.
71
+ device.resetToRootPoetryList()
72
+
73
+ // Now reset for the actual counting.
74
+ renderPassCountingInterceptor.reset()
75
+
69
76
device.openRavenAndNavigate()
70
77
71
78
val totalRenderPasses = renderPassCountingInterceptor.renderEfficiencyTracking.totalRenderPasses
@@ -78,6 +85,7 @@ class RenderPassTest {
78
85
subject = renderPassSubject,
79
86
by = by,
80
87
value = " $totalRenderPasses " ,
88
+ oldValue = " ${scenario.expectedPasses} " ,
81
89
scenario = scenario.title
82
90
)
83
91
} else if (totalRenderPasses < scenario.expectedPasses) {
@@ -88,6 +96,7 @@ class RenderPassTest {
88
96
subject = renderPassSubject,
89
97
by = by,
90
98
value = " $totalRenderPasses " ,
99
+ oldValue = " ${scenario.expectedPasses} " ,
91
100
scenario = scenario.title
92
101
)
93
102
}
@@ -103,8 +112,12 @@ class RenderPassTest {
103
112
104
113
val ratioSubject = " the fresh rendering ratio (higher better)"
105
114
val ratioString = " %.3f" .format(freshRatio)
115
+ val oldRatioString = " %.3f" .format(expectedRatio)
106
116
val valueString = " (ratio: $ratioString ; fresh renderings: $freshRenderings ;" +
107
117
" stale renderings: $staleRenderings )"
118
+ val oldValueString =
119
+ " (ratio: $oldRatioString ; fresh renderings: ${scenario.expectedFreshRenderings} ;" +
120
+ " stale renderings: ${scenario.expectedStaleRenderings} )"
108
121
109
122
if (freshRatio > expectedRatio) {
110
123
// Something has 'improved' - let's see if we reduced stale nodes.
@@ -114,9 +127,20 @@ class RenderPassTest {
114
127
" %.2f" .format(100.0 * (diff.toDouble() / scenario.expectedStaleRenderings.toDouble()))
115
128
val by = " rendering $diff fewer stale nodes" +
116
129
" (reducing by $percentage % to $staleRenderings )"
117
- congrats(subject = ratioSubject, by = by, value = valueString, scenario = scenario.title)
130
+ congrats(
131
+ subject = ratioSubject,
132
+ by = by,
133
+ value = valueString,
134
+ oldValue = oldValueString,
135
+ scenario = scenario.title
136
+ )
118
137
} else {
119
- meh(ratioSubject, valueString, scenario.title)
138
+ meh(
139
+ subject = ratioSubject,
140
+ value = valueString,
141
+ oldValue = oldValueString,
142
+ scenario = scenario.title
143
+ )
120
144
}
121
145
} else if (freshRatio < expectedRatio) {
122
146
// Something has 'worsened' - let's see if we increased stale nodes.
@@ -126,9 +150,20 @@ class RenderPassTest {
126
150
" %.2f" .format(100.0 * (diff.toDouble() / scenario.expectedStaleRenderings.toDouble()))
127
151
val by = " rendering $diff more stale nodes" +
128
152
" (increasing by $percentage % to $staleRenderings )"
129
- uhOh(subject = ratioSubject, by = by, value = valueString, scenario = scenario.title)
153
+ uhOh(
154
+ subject = ratioSubject,
155
+ by = by,
156
+ value = valueString,
157
+ oldValue = oldValueString,
158
+ scenario = scenario.title
159
+ )
130
160
} else {
131
- meh(ratioSubject, valueString, scenario.title)
161
+ meh(
162
+ subject = ratioSubject,
163
+ value = valueString,
164
+ oldValue = oldValueString,
165
+ scenario = scenario.title
166
+ )
132
167
}
133
168
}
134
169
}
@@ -141,9 +176,9 @@ class RenderPassTest {
141
176
useInitializingState = true ,
142
177
complexityDelay = 100L
143
178
),
144
- expectedPasses = 57 ,
145
- expectedFreshRenderings = 83 ,
146
- expectedStaleRenderings = 615
179
+ expectedPasses = 58 ,
180
+ expectedFreshRenderings = 85 ,
181
+ expectedStaleRenderings = 617
147
182
)
148
183
149
184
val COMPLEX_NO_INITIALIZING = Scenario (
@@ -153,41 +188,45 @@ class RenderPassTest {
153
188
useInitializingState = false ,
154
189
complexityDelay = 100L
155
190
),
156
- expectedPasses = 58 ,
157
- expectedFreshRenderings = 84 ,
158
- expectedStaleRenderings = 636
191
+ expectedPasses = 56 ,
192
+ expectedFreshRenderings = 83 ,
193
+ expectedStaleRenderings = 605
159
194
)
160
195
161
196
fun congrats (
162
197
subject : String ,
163
198
value : String ,
199
+ oldValue : String ,
164
200
scenario : String ,
165
201
by : String? = null
166
202
) = fail(
167
- " Congrats! You have improved the $subject ${by?.let { " by $by " }} in $scenario !" +
168
- " Please update the expected value for your config. The value is now $value ."
203
+ " Congrats! You have improved the $subject ${by?.let { " by $by " } ? : " " } in $scenario !" +
204
+ " Please update the expected value for your config. The value is now $value " +
205
+ " (was $oldValue )."
169
206
)
170
207
171
208
fun uhOh (
172
209
subject : String ,
173
210
value : String ,
211
+ oldValue : String ,
174
212
scenario : String ,
175
213
by : String? = null
176
214
) = fail(
177
- " Uh Oh! You have worsened the $subject ${by?.let { " by $by " }} in $scenario !" +
178
- " The value is now $value . This likely results in worse performance." +
215
+ " Uh Oh! You have worsened the $subject ${by?.let { " by $by " } ? : " " } in $scenario !" +
216
+ " The value is now $value (was $oldValue ) . This likely results in worse performance." +
179
217
" You can check with the timing benchmarks if you disagree."
180
218
)
181
219
182
220
fun meh (
183
221
subject : String ,
184
222
value : String ,
223
+ oldValue : String ,
185
224
scenario : String ,
186
225
by : String? = null
187
226
) = fail(
188
- " Hmmm. The $subject has improved ${by?.let { " by $by " }} in $scenario ," +
227
+ " Hmmm. The $subject has improved ${by?.let { " by $by " } ? : " " } in $scenario ," +
189
228
" but only because the scenario has changed, impacting expectation" +
190
- " but not for the better. The value is now $value . Please update the test."
229
+ " but not for the better. The value is now $value (was $oldValue ) . Please update the test."
191
230
)
192
231
}
193
232
}
0 commit comments