@@ -93,6 +93,27 @@ void RunAddRectsBenchmark(benchmark::State& state, int maxSize) {
93
93
94
94
while (state.KeepRunning ()) {
95
95
Region region (rects);
96
+ }
97
+ }
98
+
99
+ template <typename Region>
100
+ void RunGetRectsBenchmark (benchmark::State& state, int maxSize) {
101
+ std::random_device d;
102
+ std::seed_seq seed{2 , 1 , 3 };
103
+ std::mt19937 rng (seed);
104
+
105
+ std::uniform_int_distribution pos (0 , 4000 );
106
+ std::uniform_int_distribution size (1 , maxSize);
107
+
108
+ std::vector<SkIRect> rects;
109
+ for (int i = 0 ; i < 2000 ; ++i) {
110
+ SkIRect rect = SkIRect::MakeXYWH (pos (rng), pos (rng), size (rng), size (rng));
111
+ rects.push_back (rect);
112
+ }
113
+
114
+ Region region (rects);
115
+
116
+ while (state.KeepRunning ()) {
96
117
auto vec2 = region.getRects ();
97
118
}
98
119
}
@@ -195,6 +216,14 @@ static void BM_SkRegion_AddRects(benchmark::State& state, int maxSize) {
195
216
RunAddRectsBenchmark<SkRegionAdapter>(state, maxSize);
196
217
}
197
218
219
+ static void BM_DlRegion_GetRects (benchmark::State& state, int maxSize) {
220
+ RunGetRectsBenchmark<DlRegionAdapter>(state, maxSize);
221
+ }
222
+
223
+ static void BM_SkRegion_GetRects (benchmark::State& state, int maxSize) {
224
+ RunGetRectsBenchmark<SkRegionAdapter>(state, maxSize);
225
+ }
226
+
198
227
static void BM_DlRegion_MakeUnion (benchmark::State& state, int maxSize) {
199
228
RunUnionRegionBenchmark<DlRegionAdapter>(state, maxSize);
200
229
}
@@ -289,4 +318,21 @@ BENCHMARK_CAPTURE(BM_DlRegion_AddRects, Large, 1500)
289
318
BENCHMARK_CAPTURE (BM_SkRegion_AddRects, Large, 1500 )
290
319
->Unit (benchmark::kMicrosecond );
291
320
321
+ BENCHMARK_CAPTURE (BM_DlRegion_GetRects, Tiny, 30 )
322
+ ->Unit (benchmark::kMicrosecond );
323
+ BENCHMARK_CAPTURE (BM_SkRegion_GetRects, Tiny, 30 )
324
+ ->Unit (benchmark::kMicrosecond );
325
+ BENCHMARK_CAPTURE (BM_DlRegion_GetRects, Small, 100 )
326
+ ->Unit (benchmark::kMicrosecond );
327
+ BENCHMARK_CAPTURE (BM_SkRegion_GetRects, Small, 100 )
328
+ ->Unit (benchmark::kMicrosecond );
329
+ BENCHMARK_CAPTURE (BM_DlRegion_GetRects, Medium, 400 )
330
+ ->Unit (benchmark::kMicrosecond );
331
+ BENCHMARK_CAPTURE (BM_SkRegion_GetRects, Medium, 400 )
332
+ ->Unit (benchmark::kMicrosecond );
333
+ BENCHMARK_CAPTURE (BM_DlRegion_GetRects, Large, 1500 )
334
+ ->Unit (benchmark::kMicrosecond );
335
+ BENCHMARK_CAPTURE (BM_SkRegion_GetRects, Large, 1500 )
336
+ ->Unit (benchmark::kMicrosecond );
337
+
292
338
} // namespace flutter
0 commit comments