5#ifndef FLUTTER_DISPLAY_LIST_BENCHMARKING_DL_BENCHMARKS_H_
6#define FLUTTER_DISPLAY_LIST_BENCHMARKING_DL_BENCHMARKS_H_
8#include "flutter/display_list/dl_canvas.h"
9#include "flutter/display_list/dl_sampling_options.h"
10#include "flutter/display_list/dl_vertices.h"
11#include "flutter/display_list/testing/dl_test_surface_provider.h"
13#include "third_party/benchmark/include/benchmark/benchmark.h"
94 bool transparent_occluder,
103#define DRAW_LINE_BENCHMARKS(BACKEND, ATTRIBUTES) \
104 BENCHMARK_CAPTURE(BM_DrawLine, BACKEND, \
105 BackendType::k##BACKEND##Backend, \
107 ->RangeMultiplier(2) \
110 ->Unit(benchmark::kMillisecond);
113#define DRAW_RECT_BENCHMARKS(BACKEND, ATTRIBUTES) \
114 BENCHMARK_CAPTURE(BM_DrawRect, BACKEND, \
115 BackendType::k##BACKEND##Backend, \
117 ->RangeMultiplier(2) \
120 ->Unit(benchmark::kMillisecond);
123#define DRAW_OVAL_BENCHMARKS(BACKEND, ATTRIBUTES) \
124 BENCHMARK_CAPTURE(BM_DrawOval, BACKEND, \
125 BackendType::k##BACKEND##Backend, \
127 ->RangeMultiplier(2) \
130 ->Unit(benchmark::kMillisecond);
133#define DRAW_CIRCLE_BENCHMARKS(BACKEND, ATTRIBUTES) \
134 BENCHMARK_CAPTURE(BM_DrawCircle, BACKEND, \
135 BackendType::k##BACKEND##Backend, \
137 ->RangeMultiplier(2) \
140 ->Unit(benchmark::kMillisecond);
143#define DRAW_ARC_BENCHMARKS(BACKEND, ATTRIBUTES) \
144 BENCHMARK_CAPTURE(BM_DrawArc, BACKEND, \
145 BackendType::k##BACKEND##Backend, \
147 ->RangeMultiplier(2) \
150 ->Unit(benchmark::kMillisecond);
153#define DRAW_PATH_BENCHMARKS(BACKEND, ATTRIBUTES) \
154 BENCHMARK_CAPTURE(BM_DrawPath, \
156 BackendType::k##BACKEND##Backend, \
158 SkPath::Verb::kLine_Verb) \
159 ->RangeMultiplier(2) \
162 ->Unit(benchmark::kMillisecond) \
165 BENCHMARK_CAPTURE(BM_DrawPath, \
167 BackendType::k##BACKEND##Backend, \
169 SkPath::Verb::kQuad_Verb) \
170 ->RangeMultiplier(2) \
173 ->Unit(benchmark::kMillisecond) \
176 BENCHMARK_CAPTURE(BM_DrawPath, \
178 BackendType::k##BACKEND##Backend, \
180 SkPath::Verb::kConic_Verb) \
181 ->RangeMultiplier(2) \
184 ->Unit(benchmark::kMillisecond) \
187 BENCHMARK_CAPTURE(BM_DrawPath, \
189 BackendType::k##BACKEND##Backend, \
191 SkPath::Verb::kCubic_Verb) \
192 ->RangeMultiplier(2) \
195 ->Unit(benchmark::kMillisecond) \
199#define DRAW_POINTS_BENCHMARKS(BACKEND, ATTRIBUTES) \
200 BENCHMARK_CAPTURE(BM_DrawPoints, Points/BACKEND, \
201 BackendType::k##BACKEND##Backend, \
203 DlCanvas::PointMode::kPoints) \
204 ->RangeMultiplier(2) \
205 ->Range(1024, 32768) \
207 ->Unit(benchmark::kMillisecond); \
209 BENCHMARK_CAPTURE(BM_DrawPoints, Lines/BACKEND, \
210 BackendType::k##BACKEND##Backend, \
212 DlCanvas::PointMode::kLines) \
213 ->RangeMultiplier(2) \
214 ->Range(1024, 32768) \
216 ->Unit(benchmark::kMillisecond); \
218 BENCHMARK_CAPTURE(BM_DrawPoints, Polygon/BACKEND, \
219 BackendType::k##BACKEND##Backend, \
221 DlCanvas::PointMode::kPolygon) \
222 ->RangeMultiplier(2) \
223 ->Range(1024, 32768) \
225 ->Unit(benchmark::kMillisecond);
228#define DRAW_VERTICES_BENCHMARKS(BACKEND, ATTRIBUTES) \
229 BENCHMARK_CAPTURE(BM_DrawVertices, \
230 TriangleStrip/BACKEND, \
231 BackendType::k##BACKEND##Backend, \
233 DlVertexMode::kTriangleStrip) \
234 ->RangeMultiplier(2) \
237 ->Unit(benchmark::kMillisecond) \
240 BENCHMARK_CAPTURE(BM_DrawVertices, \
241 TriangleFan/BACKEND, \
242 BackendType::k##BACKEND##Backend, \
244 DlVertexMode::kTriangleFan) \
245 ->RangeMultiplier(2) \
248 ->Unit(benchmark::kMillisecond) \
251 BENCHMARK_CAPTURE(BM_DrawVertices, \
253 BackendType::k##BACKEND##Backend, \
255 DlVertexMode::kTriangles) \
256 ->RangeMultiplier(2) \
259 ->Unit(benchmark::kMillisecond) \
263#define DRAW_RRECT_BENCHMARKS(BACKEND, ATTRIBUTES) \
264 BENCHMARK_CAPTURE(BM_DrawRRect, Symmetric/BACKEND, \
265 BackendType::k##BACKEND##Backend, \
267 SkRRect::Type::kSimple_Type) \
268 ->RangeMultiplier(2) \
271 ->Unit(benchmark::kMillisecond); \
273 BENCHMARK_CAPTURE(BM_DrawRRect, NinePatch/BACKEND, \
274 BackendType::k##BACKEND##Backend, \
276 SkRRect::Type::kNinePatch_Type) \
277 ->RangeMultiplier(2) \
280 ->Unit(benchmark::kMillisecond); \
282 BENCHMARK_CAPTURE(BM_DrawRRect, Complex/BACKEND, \
283 BackendType::k##BACKEND##Backend, \
285 SkRRect::Type::kComplex_Type) \
286 ->RangeMultiplier(2) \
289 ->Unit(benchmark::kMillisecond);
292#define DRAW_DRRECT_BENCHMARKS(BACKEND, ATTRIBUTES) \
293 BENCHMARK_CAPTURE(BM_DrawDRRect, Symmetric/BACKEND, \
294 BackendType::k##BACKEND##Backend, \
296 SkRRect::Type::kSimple_Type) \
297 ->RangeMultiplier(2) \
300 ->Unit(benchmark::kMillisecond); \
302 BENCHMARK_CAPTURE(BM_DrawDRRect, NinePatch/BACKEND, \
303 BackendType::k##BACKEND##Backend, \
305 SkRRect::Type::kNinePatch_Type) \
306 ->RangeMultiplier(2) \
309 ->Unit(benchmark::kMillisecond); \
311 BENCHMARK_CAPTURE(BM_DrawDRRect, Complex/BACKEND, \
312 BackendType::k##BACKEND##Backend, \
314 SkRRect::Type::kComplex_Type) \
315 ->RangeMultiplier(2) \
318 ->Unit(benchmark::kMillisecond);
321#define DRAW_IMAGE_BENCHMARKS(BACKEND, ATTRIBUTES) \
322 BENCHMARK_CAPTURE(BM_DrawImage, Texture/BACKEND, \
323 BackendType::k##BACKEND##Backend, \
325 DlImageSampling::kNearestNeighbor, false) \
326 ->RangeMultiplier(2) \
329 ->Unit(benchmark::kMillisecond); \
331 BENCHMARK_CAPTURE(BM_DrawImage, Upload/BACKEND, \
332 BackendType::k##BACKEND##Backend, \
334 DlImageSampling::kNearestNeighbor, true) \
335 ->RangeMultiplier(2) \
338 ->Unit(benchmark::kMillisecond);
341#define DRAW_IMAGE_RECT_BENCHMARKS(BACKEND, ATTRIBUTES) \
343 BM_DrawImageRect, Texture/Strict/BACKEND, \
344 BackendType::k##BACKEND##Backend, \
346 DlImageSampling::kNearestNeighbor, \
347 DlCanvas::SrcRectConstraint::kStrict, false) \
348 ->RangeMultiplier(2) \
351 ->Unit(benchmark::kMillisecond); \
354 BM_DrawImageRect, Texture/Fast/BACKEND, \
355 BackendType::k##BACKEND##Backend, \
357 DlImageSampling::kNearestNeighbor, \
358 DlCanvas::SrcRectConstraint::kFast, false) \
359 ->RangeMultiplier(2) \
362 ->Unit(benchmark::kMillisecond); \
365 BM_DrawImageRect, Upload/Strict/BACKEND, \
366 BackendType::k##BACKEND##Backend, \
368 DlImageSampling::kNearestNeighbor, \
369 DlCanvas::SrcRectConstraint::kStrict, true) \
370 ->RangeMultiplier(2) \
373 ->Unit(benchmark::kMillisecond); \
376 BM_DrawImageRect, Upload/Fast/BACKEND, \
377 BackendType::k##BACKEND##Backend, \
379 DlImageSampling::kNearestNeighbor, \
380 DlCanvas::SrcRectConstraint::kFast, true) \
381 ->RangeMultiplier(2) \
384 ->Unit(benchmark::kMillisecond);
387#define DRAW_IMAGE_NINE_BENCHMARKS(BACKEND, ATTRIBUTES) \
388 BENCHMARK_CAPTURE(BM_DrawImageNine, Texture/Nearest/BACKEND, \
389 BackendType::k##BACKEND##Backend, \
391 DlFilterMode::kNearest, false) \
392 ->RangeMultiplier(2) \
395 ->Unit(benchmark::kMillisecond); \
397 BENCHMARK_CAPTURE(BM_DrawImageNine, Upload/Nearest/BACKEND, \
398 BackendType::k##BACKEND##Backend, \
400 DlFilterMode::kNearest, true) \
401 ->RangeMultiplier(2) \
404 ->Unit(benchmark::kMillisecond); \
406 BENCHMARK_CAPTURE(BM_DrawImageNine, Texture/Linear/BACKEND, \
407 BackendType::k##BACKEND##Backend, \
409 DlFilterMode::kLinear, false) \
410 ->RangeMultiplier(2) \
413 ->Unit(benchmark::kMillisecond); \
415 BENCHMARK_CAPTURE(BM_DrawImageNine, Upload/Linear/BACKEND, \
416 BackendType::k##BACKEND##Backend, \
418 DlFilterMode::kLinear, true) \
419 ->RangeMultiplier(2) \
422 ->Unit(benchmark::kMillisecond);
425#define DRAW_TEXT_BLOB_BENCHMARKS(BACKEND, ATTRIBUTES) \
426 BENCHMARK_CAPTURE(BM_DrawTextBlob, BACKEND, \
427 BackendType::k##BACKEND##Backend, \
429 ->RangeMultiplier(2) \
432 ->Unit(benchmark::kMillisecond) \
436#define DRAW_SHADOW_BENCHMARKS(BACKEND, ATTRIBUTES) \
437 BENCHMARK_CAPTURE(BM_DrawShadow, Lines/Transparent/BACKEND, \
438 BackendType::k##BACKEND##Backend, \
441 SkPath::Verb::kLine_Verb) \
442 ->RangeMultiplier(2) \
445 ->Unit(benchmark::kMillisecond); \
447 BENCHMARK_CAPTURE(BM_DrawShadow, Quads/Transparent/BACKEND, \
448 BackendType::k##BACKEND##Backend, \
451 SkPath::Verb::kQuad_Verb) \
452 ->RangeMultiplier(2) \
455 ->Unit(benchmark::kMillisecond); \
457 BENCHMARK_CAPTURE(BM_DrawShadow, Conics/Transparent/BACKEND, \
458 BackendType::k##BACKEND##Backend, \
461 SkPath::Verb::kConic_Verb) \
462 ->RangeMultiplier(2) \
465 ->Unit(benchmark::kMillisecond); \
467 BENCHMARK_CAPTURE(BM_DrawShadow, Cubics/Transparent/BACKEND, \
468 BackendType::k##BACKEND##Backend, \
471 SkPath::Verb::kCubic_Verb) \
472 ->RangeMultiplier(2) \
475 ->Unit(benchmark::kMillisecond); \
477 BENCHMARK_CAPTURE(BM_DrawShadow, Lines/Opaque/BACKEND, \
478 BackendType::k##BACKEND##Backend, \
481 SkPath::Verb::kLine_Verb) \
482 ->RangeMultiplier(2) \
485 ->Unit(benchmark::kMillisecond); \
487 BENCHMARK_CAPTURE(BM_DrawShadow, Quads/Opaque/BACKEND, \
488 BackendType::k##BACKEND##Backend, \
491 SkPath::Verb::kQuad_Verb) \
492 ->RangeMultiplier(2) \
495 ->Unit(benchmark::kMillisecond); \
497 BENCHMARK_CAPTURE(BM_DrawShadow, Conics/Opaque/BACKEND, \
498 BackendType::k##BACKEND##Backend, \
501 SkPath::Verb::kConic_Verb) \
502 ->RangeMultiplier(2) \
505 ->Unit(benchmark::kMillisecond); \
507 BENCHMARK_CAPTURE(BM_DrawShadow, Cubics/Opaque/BACKEND, \
508 BackendType::k##BACKEND##Backend, \
511 SkPath::Verb::kCubic_Verb) \
512 ->RangeMultiplier(2) \
515 ->Unit(benchmark::kMillisecond);
518#define SAVE_LAYER_BENCHMARKS(BACKEND, ATTRIBUTES) \
519 BENCHMARK_CAPTURE(BM_SaveLayer, Depth 1/BACKEND, \
520 BackendType::k##BACKEND##Backend, \
523 ->RangeMultiplier(2) \
526 ->Unit(benchmark::kMillisecond); \
528 BENCHMARK_CAPTURE(BM_SaveLayer, Depth 8/BACKEND, \
529 BackendType::k##BACKEND##Backend, \
532 ->RangeMultiplier(2) \
535 ->Unit(benchmark::kMillisecond);
538#define STROKE_BENCHMARKS(BACKEND, ATTRIBUTES) \
539 DRAW_LINE_BENCHMARKS(BACKEND, ATTRIBUTES) \
540 DRAW_POINTS_BENCHMARKS(BACKEND, ATTRIBUTES) \
541 DRAW_RECT_BENCHMARKS(BACKEND, ATTRIBUTES) \
542 DRAW_OVAL_BENCHMARKS(BACKEND, ATTRIBUTES) \
543 DRAW_CIRCLE_BENCHMARKS(BACKEND, ATTRIBUTES) \
544 DRAW_ARC_BENCHMARKS(BACKEND, ATTRIBUTES) \
545 DRAW_PATH_BENCHMARKS(BACKEND, ATTRIBUTES) \
546 DRAW_RRECT_BENCHMARKS(BACKEND, ATTRIBUTES) \
547 DRAW_DRRECT_BENCHMARKS(BACKEND, ATTRIBUTES) \
548 DRAW_TEXT_BLOB_BENCHMARKS(BACKEND, ATTRIBUTES)
551#define FILL_BENCHMARKS(BACKEND, ATTRIBUTES) \
552 DRAW_RECT_BENCHMARKS(BACKEND, ATTRIBUTES) \
553 DRAW_OVAL_BENCHMARKS(BACKEND, ATTRIBUTES) \
554 DRAW_CIRCLE_BENCHMARKS(BACKEND, ATTRIBUTES) \
555 DRAW_ARC_BENCHMARKS(BACKEND, ATTRIBUTES) \
556 DRAW_PATH_BENCHMARKS(BACKEND, ATTRIBUTES) \
557 DRAW_RRECT_BENCHMARKS(BACKEND, ATTRIBUTES) \
558 DRAW_DRRECT_BENCHMARKS(BACKEND, ATTRIBUTES) \
559 DRAW_TEXT_BLOB_BENCHMARKS(BACKEND, ATTRIBUTES)
562#define ANTI_ALIASING_BENCHMARKS(BACKEND, ATTRIBUTES) \
563 DRAW_IMAGE_BENCHMARKS(BACKEND, ATTRIBUTES) \
564 DRAW_IMAGE_RECT_BENCHMARKS(BACKEND, ATTRIBUTES)
567#define OTHER_BENCHMARKS(BACKEND, ATTRIBUTES) \
568 DRAW_IMAGE_NINE_BENCHMARKS(BACKEND, ATTRIBUTES) \
569 DRAW_VERTICES_BENCHMARKS(BACKEND, ATTRIBUTES) \
570 DRAW_SHADOW_BENCHMARKS(BACKEND, ATTRIBUTES) \
571 SAVE_LAYER_BENCHMARKS(BACKEND, ATTRIBUTES)
573#define RUN_DISPLAYLIST_BENCHMARKS(BACKEND) \
574 STROKE_BENCHMARKS(BACKEND, kStrokedStyle) \
575 STROKE_BENCHMARKS(BACKEND, kStrokedStyle | kAntiAliasing) \
576 STROKE_BENCHMARKS(BACKEND, kStrokedStyle | kHairlineStroke) \
577 STROKE_BENCHMARKS(BACKEND, kStrokedStyle | kHairlineStroke | \
579 FILL_BENCHMARKS(BACKEND, kFilledStyle) \
580 FILL_BENCHMARKS(BACKEND, kFilledStyle | kAntiAliasing) \
581 ANTI_ALIASING_BENCHMARKS(BACKEND, kEmpty) \
582 ANTI_ALIASING_BENCHMARKS(BACKEND, kAntiAliasing) \
583 OTHER_BENCHMARKS(BACKEND, kEmpty)
void BM_DrawVertices(benchmark::State &state, BackendType backend_type, unsigned attributes, DlVertexMode mode)
void BM_DrawRRect(benchmark::State &state, BackendType backend_type, unsigned attributes, SkRRect::Type type)
void BM_DrawPath(benchmark::State &state, BackendType backend_type, unsigned attributes, SkPath::Verb type)
void BM_DrawShadow(benchmark::State &state, BackendType backend_type, unsigned attributes, bool transparent_occluder, SkPath::Verb type)
void BM_DrawImageRect(benchmark::State &state, BackendType backend_type, unsigned attributes, DlImageSampling options, DlCanvas::SrcRectConstraint constraint, bool upload_bitmap)
void BM_DrawOval(benchmark::State &state, BackendType backend_type, unsigned attributes)
void BM_DrawImage(benchmark::State &state, BackendType backend_type, unsigned attributes, DlImageSampling options, bool upload_bitmap)
void BM_DrawLine(benchmark::State &state, BackendType backend_type, unsigned attributes)
void BM_DrawCircle(benchmark::State &state, BackendType backend_type, unsigned attributes)
void BM_DrawRect(benchmark::State &state, BackendType backend_type, unsigned attributes)
void BM_DrawDRRect(benchmark::State &state, BackendType backend_type, unsigned attributes, SkRRect::Type type)
void BM_DrawTextBlob(benchmark::State &state, BackendType backend_type, unsigned attributes)
void BM_DrawArc(benchmark::State &state, BackendType backend_type, unsigned attributes)
void BM_DrawImageNine(benchmark::State &state, BackendType backend_type, unsigned attributes, const DlFilterMode filter, bool upload_bitmap)
void BM_DrawPoints(benchmark::State &state, BackendType backend_type, unsigned attributes, DlCanvas::PointMode mode)
void BM_SaveLayer(benchmark::State &state, BackendType backend_type, unsigned attributes, size_t save_depth)
DlPaint GetPaintForRun(unsigned attributes)
DlVertexMode
Defines the way in which the vertices of a DlVertices object are separated into triangles into which ...
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode