| # Copyright 2017 Google Inc. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| def query_surfaceflinger_frame_count(): |
| parcel = subprocess.Popen("adb shell service call SurfaceFlinger 1013", |
| stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
| shell=True).communicate()[0] |
| raise Exception("FAILED: adb shell service call SurfaceFlinger 1013") |
| framecount = re.search("Result: Parcel\(([a-f0-9]+) ", parcel) |
| raise Exception("Unexpected result from SurfaceFlinger: " + parcel) |
| return int(framecount.group(1), 16) |
| startframe = query_surfaceflinger_frame_count() |
| endframe = query_surfaceflinger_frame_count() |
| fps = (endframe - startframe) / (endtime - starttime) |
| 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() |