1cb93a386Sopenharmony_ciMeasuring the performance of CanvasKit using Puppeteer and Chrome.
2cb93a386Sopenharmony_ci
3cb93a386Sopenharmony_ci## Initial setup
4cb93a386Sopenharmony_ci
5cb93a386Sopenharmony_ciRun `npm ci` to install the dependencies need to run the tests. In //modules/canvaskit, run
6cb93a386Sopenharmony_ci`make release` to build the canvaskit that will be used. With modifications to the Makefile,
7cb93a386Sopenharmony_ciother builds (e.g. `make profile`) can be used as well.
8cb93a386Sopenharmony_ci
9cb93a386Sopenharmony_ciIf needed, one can download the lottie-samples and/or skp assets from CIPD using the sk tool:
10cb93a386Sopenharmony_ci```
11cb93a386Sopenharmony_cisk asset download lottie-samples ~/Downloads/lottie-samples
12cb93a386Sopenharmony_cisk asset download skps ~/Downloads/skps
13cb93a386Sopenharmony_ci```
14cb93a386Sopenharmony_ci
15cb93a386Sopenharmony_ciThe actual location that these assets can be downloaded to is not important - the Makefile assumes
16cb93a386Sopenharmony_cithem to be in Downloads, but that can be modified by the local user.
17cb93a386Sopenharmony_ci
18cb93a386Sopenharmony_ci## Basic Performance Tests
19cb93a386Sopenharmony_ciWe have a harness for running benchmarks. Benchmark code snippets can be added to `canvas_perf.js`.
20cb93a386Sopenharmony_ciThe harness itself is the `canvas_perf.html` and `benchmark.js`. It will run the "test" portion of
21cb93a386Sopenharmony_cithe code on multiple frames and gather data.
22cb93a386Sopenharmony_ci
23cb93a386Sopenharmony_ciTo run the benchmarks, run `make perf_js`. By default, this will use the most recent release build
24cb93a386Sopenharmony_ciof canvaskit done locally. If you want to only run one or a few, modify the
25cb93a386Sopenharmony_ci`canvas_perf.js` file by changing the relevent `tests.push` to `onlytests.push` and then run
26cb93a386Sopenharmony_ci`make perf_js`.
27cb93a386Sopenharmony_ci
28cb93a386Sopenharmony_ciOn the CI, the results from these tests are uploaded to Perf. For example:
29cb93a386Sopenharmony_ci<https://perf.skia.org/e/?queries=test%3Dcanvas_drawOval>
30cb93a386Sopenharmony_ciWe include metrics such as the 90th, 95th, and 99th percentile frame, average frame time, median
31cb93a386Sopenharmony_ciframe time, and standard deviation. There are three types of measurements: without_flush_ms is
32cb93a386Sopenharmony_cithe measurement of the test() function; with_flush_ms is the measurement of test() and the
33cb93a386Sopenharmony_cisubsequent flush() call; total_frame_ms is the frame-to-frame time. Frame-to-frame is important to
34cb93a386Sopenharmony_cimeasure because it accounts for any work the GPU needs to do, even after CanvasKit flushes.
35cb93a386Sopenharmony_ci
36cb93a386Sopenharmony_ci## Skottie Frames Performance
37cb93a386Sopenharmony_ciThere is a harness that gathers data about rendering 600 frames of a skottie animation, cycling
38cb93a386Sopenharmony_cithrough it in a similar fashion to how it would be displayed to a user (e.g. as it is on
39cb93a386Sopenharmony_ciskottie.skia.org).
40cb93a386Sopenharmony_ci
41cb93a386Sopenharmony_ciTo test it locally with a specific skottie animation, feel free to modify the Makefile to adjust the
42cb93a386Sopenharmony_ci`input_lottie` argument and then run `make frames`. The harness itself is `skottie-frames.html` and
43cb93a386Sopenharmony_ci`benchmark.js`.
44cb93a386Sopenharmony_ci
45cb93a386Sopenharmony_ciOn the CI, the results from these tests are uploaded to Perf. For example:
46cb93a386Sopenharmony_ci<https://perf.skia.org/e/?queries=test%3Dlego_loader>
47cb93a386Sopenharmony_ciWe include metrics such as the first 5 frame times, average frame times, 90th, 95th and 99th
48cb93a386Sopenharmony_cipercentile frame time.
49cb93a386Sopenharmony_ci
50cb93a386Sopenharmony_ci## SKP Performance
51cb93a386Sopenharmony_ciThere is a harness that repeatedly will draw an SKP and measure various metrics. This is handled
52cb93a386Sopenharmony_ciby `skottie-frames.html` and `benchmark.js`. As before, feel free to modify the Makefile (the
53cb93a386Sopenharmony_ci`input_skp` argument) and run `make skp`.
54cb93a386Sopenharmony_ci
55cb93a386Sopenharmony_ciOn the CI, the results from these tests are uploaded to Perf. For example:
56cb93a386Sopenharmony_ci<https://perf.skia.org/e/?queries=binary%3DCanvasKit%26test%3Ddesk_chalkboard.skp>