1*8975f5c5SAndroid Build Coastguard Worker# ANGLE Performance Tests 2*8975f5c5SAndroid Build Coastguard Worker 3*8975f5c5SAndroid Build Coastguard Worker`angle_perftests` is a standalone microbenchmark testing suite that contains 4*8975f5c5SAndroid Build Coastguard Workertests for the OpenGL API. `angle_trace_tests` is a suite to run captures traces for correctness and 5*8975f5c5SAndroid Build Coastguard Workerperformance. Because the traces contain confidential data, they are not publicly available. 6*8975f5c5SAndroid Build Coastguard WorkerFor more details on ANGLE's tracer please see the [docs](../restricted_traces/README.md). 7*8975f5c5SAndroid Build Coastguard Worker 8*8975f5c5SAndroid Build Coastguard WorkerThe tests currently run on the Chromium ANGLE infrastructure and report 9*8975f5c5SAndroid Build Coastguard Workerresults to the [Chromium perf dashboard](https://chromeperf.appspot.com/report). 10*8975f5c5SAndroid Build Coastguard Worker Please refer to the[public dashboard docs][DashboardDocs] for help 11*8975f5c5SAndroid Build Coastguard Worker 12*8975f5c5SAndroid Build Coastguard Worker[DashboardDocs]: https://chromium.googlesource.com/catapult/+/HEAD/dashboard/README.md 13*8975f5c5SAndroid Build Coastguard Worker 14*8975f5c5SAndroid Build Coastguard Worker## Running the Tests 15*8975f5c5SAndroid Build Coastguard Worker 16*8975f5c5SAndroid Build Coastguard WorkerYou can follow the usual instructions to [check out and build ANGLE](../../../doc/DevSetup.md). 17*8975f5c5SAndroid Build Coastguard Worker Build the `angle_perftests` or `angle_trace_tests` targets. Note that all 18*8975f5c5SAndroid Build Coastguard Workertest scores are higher-is-better. You should also ensure `is_debug=false` in 19*8975f5c5SAndroid Build Coastguard Workeryour build. Running with `angle_assert_always_on` or debug validation enabled 20*8975f5c5SAndroid Build Coastguard Workeris not recommended. 21*8975f5c5SAndroid Build Coastguard Worker 22*8975f5c5SAndroid Build Coastguard WorkerVariance can be a problem when benchmarking. We have a test harness to run a 23*8975f5c5SAndroid Build Coastguard Workertests repeatedly to find a lower variance measurement. See `src/tests/run_perf_tests.py`. 24*8975f5c5SAndroid Build Coastguard Worker 25*8975f5c5SAndroid Build Coastguard WorkerTo use the script first build `angle_perftests` or `angle_trace_tests`, set 26*8975f5c5SAndroid Build Coastguard Workeryour working directory your build directory, and invoke the 27*8975f5c5SAndroid Build Coastguard Worker`run_perf_tests.py` script. Use `--test-suite` to specify your test suite, 28*8975f5c5SAndroid Build Coastguard Workerand `--filter` to specify a test filter. 29*8975f5c5SAndroid Build Coastguard Worker 30*8975f5c5SAndroid Build Coastguard Worker### Choosing the Test to Run 31*8975f5c5SAndroid Build Coastguard Worker 32*8975f5c5SAndroid Build Coastguard WorkerYou can choose individual tests to run with `--gtest_filter=*TestName*`. To 33*8975f5c5SAndroid Build Coastguard Workerselect a particular ANGLE back-end, add the name of the back-end to the test 34*8975f5c5SAndroid Build Coastguard Workerfilter. For example: `DrawCallPerfBenchmark.Run/gl` or 35*8975f5c5SAndroid Build Coastguard Worker`DrawCallPerfBenchmark.Run/d3d11`. Many tests have sub-tests that run 36*8975f5c5SAndroid Build Coastguard Workerslightly different code paths. You might need to experiment to find the right 37*8975f5c5SAndroid Build Coastguard Workersub-test and its name. 38*8975f5c5SAndroid Build Coastguard Worker 39*8975f5c5SAndroid Build Coastguard Worker### Null/No-op Configurations 40*8975f5c5SAndroid Build Coastguard Worker 41*8975f5c5SAndroid Build Coastguard WorkerANGLE implements a no-op driver for OpenGL, D3D11 and Vulkan. To run on these 42*8975f5c5SAndroid Build Coastguard Workerconfigurations use the `gl_null`, `d3d11_null` or `vulkan_null` test 43*8975f5c5SAndroid Build Coastguard Workerconfigurations. These null drivers will not do any GPU work. They will skip 44*8975f5c5SAndroid Build Coastguard Workerthe driver entirely. These null configs are useful for diagnosing performance 45*8975f5c5SAndroid Build Coastguard Workeroverhead in ANGLE code. 46*8975f5c5SAndroid Build Coastguard Worker 47*8975f5c5SAndroid Build Coastguard Worker### Command-line Arguments 48*8975f5c5SAndroid Build Coastguard Worker 49*8975f5c5SAndroid Build Coastguard WorkerEach test runs N trials and prints metrics for each trial. Trials are limited by time (default), step/frame limits can also be set. Note that at the beginning performance might be affected by hitting new code paths, cold caches etc (see warmup below) but longer runs on some devices trigger thermal throttling affecting performance (known: phones, desktop perf CI bots). 50*8975f5c5SAndroid Build Coastguard Worker 51*8975f5c5SAndroid Build Coastguard WorkerSeveral command-line arguments control how the tests run: 52*8975f5c5SAndroid Build Coastguard Worker 53*8975f5c5SAndroid Build Coastguard Worker* `--run-to-key-frame`: If the trace specifies a key frame, run to that frame and stop. Traces without a `KeyFrames` entry in their JSON will default to frame 1. This is primarily to save cycles on our bots that do screenshot quality comparison. 54*8975f5c5SAndroid Build Coastguard Worker* `--enable-trace`: Write a JSON event log that can be loaded in Chrome. 55*8975f5c5SAndroid Build Coastguard Worker* `--trace-file file`: Name of the JSON event log for `--enable-trace`. 56*8975f5c5SAndroid Build Coastguard Worker* `--steps-per-trial x`: Fixed number of steps to run for each test trial. 57*8975f5c5SAndroid Build Coastguard Worker* `--max-steps-performed x`: Upper maximum on total number of steps for the entire test run. For a quick smoke test, you can specify 1. 58*8975f5c5SAndroid Build Coastguard Worker* `--render-test-output-dir=dir`: Directory to store test artifacts (including screenshots but unlike `--screenshot-dir`, `dir` here is always a local directory regardless of platform and `--save-screenshots` isn't implied). 59*8975f5c5SAndroid Build Coastguard Worker* `--verbose`: Print extra timing information. 60*8975f5c5SAndroid Build Coastguard Worker* `--trial-time x` or `--max-trial-time x`: Run each test trial under this max time. Defaults to 10 seconds. 61*8975f5c5SAndroid Build Coastguard Worker* `--fixed-test-time x`: Run the tests until this much time has elapsed. 62*8975f5c5SAndroid Build Coastguard Worker* `--warmup`: Run a warmup phase before the test. Defaults to off. 63*8975f5c5SAndroid Build Coastguard Worker* `--fixed-test-time-with-warmup x`: Start with a warmup, then run the tests until this much time has elapsed. 64*8975f5c5SAndroid Build Coastguard Worker* `--trials`: Number of times to repeat testing. Defaults to 3. 65*8975f5c5SAndroid Build Coastguard Worker* `--no-finish`: Don't call glFinish after each test trial. 66*8975f5c5SAndroid Build Coastguard Worker* `--validation`: Enable serialization validation in the trace tests. Normally used with SwiftShader and retracing. 67*8975f5c5SAndroid Build Coastguard Worker* `--perf-counters`: Additional performance counters to include in the result output. Separate multiple entries with colons: ':'. 68*8975f5c5SAndroid Build Coastguard Worker 69*8975f5c5SAndroid Build Coastguard WorkerThe command line arguments implementations are located in [`ANGLEPerfTestArgs.cpp`](ANGLEPerfTestArgs.cpp). 70*8975f5c5SAndroid Build Coastguard Worker 71*8975f5c5SAndroid Build Coastguard Worker## Test Breakdown 72*8975f5c5SAndroid Build Coastguard Worker 73*8975f5c5SAndroid Build Coastguard Worker### Microbenchmarks 74*8975f5c5SAndroid Build Coastguard Worker 75*8975f5c5SAndroid Build Coastguard Worker* [`DrawCallPerfBenchmark`](DrawCallPerf.cpp): Runs a tight loop around DrawArarys calls. 76*8975f5c5SAndroid Build Coastguard Worker * `validation_only`: Skips all rendering. 77*8975f5c5SAndroid Build Coastguard Worker * `render_to_texture`: Render to a user Framebuffer instead of the default FBO. 78*8975f5c5SAndroid Build Coastguard Worker * `vbo_change`: Applies a Vertex Array change between each draw. 79*8975f5c5SAndroid Build Coastguard Worker * `tex_change`: Applies a Texture change between each draw. 80*8975f5c5SAndroid Build Coastguard Worker* [`UniformsBenchmark`](UniformsPerf.cpp): Tests performance of updating various uniforms counts followed by a DrawArrays call. 81*8975f5c5SAndroid Build Coastguard Worker * `vec4`: Tests `vec4` Uniforms. 82*8975f5c5SAndroid Build Coastguard Worker * `matrix`: Tests using Matrix uniforms instead of `vec4`. 83*8975f5c5SAndroid Build Coastguard Worker * `multiprogram`: Tests switching Programs between updates and draws. 84*8975f5c5SAndroid Build Coastguard Worker * `repeating`: Skip the update of uniforms before each draw call. 85*8975f5c5SAndroid Build Coastguard Worker* [`DrawElementsPerfBenchmark`](DrawElementsPerf.cpp): Similar to `DrawCallPerfBenchmark` but for indexed DrawElements calls. 86*8975f5c5SAndroid Build Coastguard Worker* [`BindingsBenchmark`](BindingPerf.cpp): Tests Buffer binding performance. Does no draw call operations. 87*8975f5c5SAndroid Build Coastguard Worker * `100_objects_allocated_every_iteration`: Tests repeated glBindBuffer with new buffers allocated each iteration. 88*8975f5c5SAndroid Build Coastguard Worker * `100_objects_allocated_at_initialization`: Tests repeated glBindBuffer the same objects each iteration. 89*8975f5c5SAndroid Build Coastguard Worker* [`TexSubImageBenchmark`](TexSubImage.cpp): Tests `glTexSubImage` update performance. 90*8975f5c5SAndroid Build Coastguard Worker* [`BufferSubDataBenchmark`](BufferSubData.cpp): Tests `glBufferSubData` update performance. 91*8975f5c5SAndroid Build Coastguard Worker* [`TextureSamplingBenchmark`](TextureSampling.cpp): Tests Texture sampling performance. 92*8975f5c5SAndroid Build Coastguard Worker* [`TextureBenchmark`](TexturesPerf.cpp): Tests Texture state change performance. 93*8975f5c5SAndroid Build Coastguard Worker* [`LinkProgramBenchmark`](LinkProgramPerfTest.cpp): Tests performance of `glLinkProgram`. 94*8975f5c5SAndroid Build Coastguard Worker* [`glmark2`](glmark2.cpp): Runs the glmark2 benchmark. 95*8975f5c5SAndroid Build Coastguard Worker 96*8975f5c5SAndroid Build Coastguard WorkerMany other tests can be found that have documentation in their classes. 97*8975f5c5SAndroid Build Coastguard Worker 98*8975f5c5SAndroid Build Coastguard Worker### Trace Tests 99*8975f5c5SAndroid Build Coastguard Worker 100*8975f5c5SAndroid Build Coastguard Worker* [`TracePerfTest`](TracePerfTest.cpp): Runs replays of restricted traces, not 101*8975f5c5SAndroid Build Coastguard Worker available publicly. To enable, read more in [`RestrictedTraceTests`](../restricted_traces/README.md) 102*8975f5c5SAndroid Build Coastguard Worker 103*8975f5c5SAndroid Build Coastguard WorkerTrace tests take command line arguments that pick the run configuration: 104*8975f5c5SAndroid Build Coastguard Worker 105*8975f5c5SAndroid Build Coastguard Worker* `--use-gl=native`: Runs the tests against the default system GLES implementation instad of your local ANGLE. 106*8975f5c5SAndroid Build Coastguard Worker* `--use-angle=backend`: Picks an ANGLE back-end. e.g. vulkan, d3d11, d3d9, gl, gles, metal, or swiftshader. Vulkan is the default. 107*8975f5c5SAndroid Build Coastguard Worker* `--offscreen`: Run with an offscreen surface instead of swapping every frame. 108*8975f5c5SAndroid Build Coastguard Worker* `--vsync`: Run with vsync enabled, and measure CPU and GPU work insead of wall clock time. 109*8975f5c5SAndroid Build Coastguard Worker* `--minimize-gpu-work`: Modify API calls so that GPU work is reduced to minimum. 110*8975f5c5SAndroid Build Coastguard Worker* `--screenshot-dir dir`: Directory to store test screenshots. Implies `--save-screenshots`. On Android this directory is on device, not local (see also `--render-test-output-dir`). Only implemented in `TracePerfTest`. 111*8975f5c5SAndroid Build Coastguard Worker* `--save-screenshots`: Save screenshots. Only implemented in `TracePerfTest`. 112*8975f5c5SAndroid Build Coastguard Worker* `--screenshot-frame <frame>`: Which frame to capture a screenshot of. Defaults to first frame (1). Using `-1` will capture every frame rendered, including those after Reset for multiple loops. Only implemented in `TracePerfTest`. 113*8975f5c5SAndroid Build Coastguard Worker* `--include-inactive-resources` : Include all resources captured at trace-time during replay. Only resources which are active during trace execution are replayed by default. 114*8975f5c5SAndroid Build Coastguard Worker 115*8975f5c5SAndroid Build Coastguard WorkerFor example, for an endless run with no warmup on swiftshader, run: 116*8975f5c5SAndroid Build Coastguard Worker 117*8975f5c5SAndroid Build Coastguard Worker`angle_trace_tests --gtest_filter=TraceTest.trex_200 --use-angle=swiftshader --trial-time 1000000` 118*8975f5c5SAndroid Build Coastguard Worker 119*8975f5c5SAndroid Build Coastguard Worker## Understanding the Metrics 120*8975f5c5SAndroid Build Coastguard Worker 121*8975f5c5SAndroid Build Coastguard Worker* `cpu_time`: Amount of CPU time consumed by an iteration of the test. This is backed by 122*8975f5c5SAndroid Build Coastguard Worker`GetProcessTimes` on Windows, `getrusage` on Linux/Android, and `zx_object_get_info` on Fuchsia. 123*8975f5c5SAndroid Build Coastguard Worker * This value may sometimes be larger than `wall_time`. That is because we are summing up the time 124*8975f5c5SAndroid Build Coastguard Workeron all CPU threads for the test. 125*8975f5c5SAndroid Build Coastguard Worker* `wall_time`: Wall time taken to run a single iteration, calculated by dividing the total wall 126*8975f5c5SAndroid Build Coastguard Workerclock time by the number of test iterations. 127*8975f5c5SAndroid Build Coastguard Worker * For trace tests, each rendered frame is an iteration. 128*8975f5c5SAndroid Build Coastguard Worker* `gpu_time`: Estimated GPU elapsed time per test iteration. We compute the estimate using GLES 129*8975f5c5SAndroid Build Coastguard Worker[timestamp queries](https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_disjoint_timer_query.txt) 130*8975f5c5SAndroid Build Coastguard Workerat the beginning and ending of each test loop. 131*8975f5c5SAndroid Build Coastguard Worker * For trace tests, this metric is only enabled in `vsync` mode. 132