From 01b0ab8dce68e49217f467aaf0446fc19e93756f Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Tue, 21 Nov 2017 16:51:53 +0000 Subject: [PATCH] derived/fps: fix divide by zero Avoid dividing by frame_count if it's zero when calculating janks_pc. --- devlib/derived/fps.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devlib/derived/fps.py b/devlib/derived/fps.py index 2695c4c..47156a4 100644 --- a/devlib/derived/fps.py +++ b/devlib/derived/fps.py @@ -177,11 +177,13 @@ class DerivedSurfaceFlingerStats(DerivedFpsStats): janks = 0 not_at_vsync = 0 + janks_pc = 0 if frame_count == 0 else janks * 100 / frame_count + return [DerivedMetric('fps', fps, 'fps'), DerivedMetric('total_frames', frame_count, 'frames'), MeasurementsCsv(csv_file), DerivedMetric('janks', janks, 'count'), - DerivedMetric('janks_pc', janks * 100 / frame_count, 'percent'), + DerivedMetric('janks_pc', janks_pc, 'percent'), DerivedMetric('missed_vsync', not_at_vsync, 'count')] def _process_without_pandas(self, measurements_csv):