Unverified Commit 4d0c487f authored by William Hesse's avatar William Hesse Committed by GitHub

Fix divide-by-zero crash in animation_bench benchmark (#137539)

If the benchmark runs out of time before it closes the drawer it is animating, it tries to divide by zero when computing the time per frame.

Don't report time per frame for activities with zero frames. This likely only happens for the close frame action, but guards are added to all time per frame computations in this benchmark.
parent 0d3cf281
...@@ -83,23 +83,29 @@ Future<void> main() async { ...@@ -83,23 +83,29 @@ Future<void> main() async {
unit: 's', unit: 's',
name: 'stock_animation_total_run_time', name: 'stock_animation_total_run_time',
); );
if (totalOpenIterationCount > 0) {
printer.addResult( printer.addResult(
description: ' Opening first frame average time', description: ' Opening first frame average time',
value: totalOpenFrameElapsedMicroseconds / totalOpenIterationCount, value: totalOpenFrameElapsedMicroseconds / totalOpenIterationCount,
unit: 'µs per frame ($totalOpenIterationCount frames)', unit: 'µs per frame ($totalOpenIterationCount frames)',
name: 'stock_animation_open_first_frame_average', name: 'stock_animation_open_first_frame_average',
); );
}
if (totalCloseIterationCount > 0) {
printer.addResult( printer.addResult(
description: ' Closing first frame average time', description: ' Closing first frame average time',
value: totalCloseFrameElapsedMicroseconds / totalCloseIterationCount, value: totalCloseFrameElapsedMicroseconds / totalCloseIterationCount,
unit: 'µs per frame ($totalCloseIterationCount frames)', unit: 'µs per frame ($totalCloseIterationCount frames)',
name: 'stock_animation_close_first_frame_average', name: 'stock_animation_close_first_frame_average',
); );
}
if (totalSubsequentFramesIterationCount > 0) {
printer.addResult( printer.addResult(
description: ' Subsequent frames average time', description: ' Subsequent frames average time',
value: totalSubsequentFramesElapsedMicroseconds / totalSubsequentFramesIterationCount, value: totalSubsequentFramesElapsedMicroseconds / totalSubsequentFramesIterationCount,
unit: 'µs per frame ($totalSubsequentFramesIterationCount frames)', unit: 'µs per frame ($totalSubsequentFramesIterationCount frames)',
name: 'stock_animation_subsequent_frame_average', name: 'stock_animation_subsequent_frame_average',
); );
}
printer.printToStdout(); printer.printToStdout();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment