testing/gtest/bench.py
author Geoff Brown <gbrown@mozilla.com>
Mon, 22 Apr 2019 15:55:23 +0000
changeset 470372 98df47a219e2088d431e3961fe6ea7f99017a1be
parent 452229 807f9818930a9992834f1770bd2fa10147019c81
permissions -rwxr-xr-x
Bug 1318091 - Support |mach gtest| for android; r=bc Add basic support for 'mach gtest' on Android. Handling of Android-only and desktop-only options is awkward; I hope to re-visit this after bug 1519369. Differential Revision: https://phabricator.services.mozilla.com/D28129

#!/usr/bin/env python3

import sys
import subprocess
import json
import statistics

proc = subprocess.Popen(["./mach", "gtest", sys.argv[1]], stdout=subprocess.PIPE)
for line in proc.stdout:
    if line.startswith(b"PERFHERDER_DATA:"):
        data = json.loads(line[len("PERFHERDER_DATA:"):].decode("utf8"))
        for suite in data["suites"]:
            for subtest in suite["subtests"]:
                print("%4d.%03d ± %6s ms    %s.%s" % (
                    subtest["value"] / 1000.,
                    subtest["value"] % 1000,
                    "%.3f" % (statistics.stdev(subtest["replicates"]) / 1000),
                    suite["name"],
                    subtest["name"],
                ))