aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-09-14 14:18:45 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-14 20:55:21 +0000
commit2d802ddba636f005d0e905a0c90e446095ad8f64 (patch)
tree0fc517d3f55ed79329ecdac43b8c4b20bfc5375d /tools
parente191ce68f00ff4b517fdf244b3311904858a25ec (diff)
Simple script to measure SurfaceFlinger fps
Bug: skia: Change-Id: I063c832f6d292e5e9f615c881e3325eb4ab9cdfa Reviewed-on: https://skia-review.googlesource.com/44681 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com> Reviewed-by: Ravi Mistry <rmistry@google.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/android/measure_fps.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/tools/android/measure_fps.py b/tools/android/measure_fps.py
new file mode 100644
index 0000000000..7ec80dcc56
--- /dev/null
+++ b/tools/android/measure_fps.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+# Copyright 2017 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import optparse
+import re
+import subprocess
+import time
+
+
+def query_surfaceflinger_frame_count():
+ parcel = subprocess.Popen("adb shell service call SurfaceFlinger 1013",
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ shell=True).communicate()[0]
+ if not parcel:
+ raise Exception("FAILED: adb shell service call SurfaceFlinger 1013")
+
+ framecount = re.search("Result: Parcel\(([a-f0-9]+) ", parcel)
+ if not framecount:
+ raise Exception("Unexpected result from SurfaceFlinger: " + parcel)
+
+ return int(framecount.group(1), 16)
+
+
+def main(interval):
+ startframe = query_surfaceflinger_frame_count()
+ starttime = time.time()
+
+ while True:
+ time.sleep(interval)
+
+ endframe = query_surfaceflinger_frame_count()
+ endtime = time.time()
+ fps = (endframe - startframe) / (endtime - starttime)
+ print "%.2f" % fps
+
+ startframe = endframe
+ starttime = endtime
+
+
+if __name__ == '__main__':
+ parser = optparse.OptionParser()
+ parser.add_option("-i", "--interval", type="int", default="2",
+ help="Number of seconds to count frames.")
+ options, args = parser.parse_args()
+ main(options.interval)
+