tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

bench.py (831B)


      1 #!/usr/bin/env python3
      2 
      3 import json
      4 import statistics
      5 import subprocess
      6 import sys
      7 
      8 proc = subprocess.Popen(["./mach", "gtest", sys.argv[1]], stdout=subprocess.PIPE)
      9 for line in proc.stdout:
     10    if line.startswith(b"PERFHERDER_DATA:"):
     11        data = json.loads(line[len("PERFHERDER_DATA:") :].decode("utf8"))
     12        for suite in data["suites"]:
     13            for subtest in suite["subtests"]:
     14                # pylint --py3k W1619
     15                print(
     16                    "%4d.%03d ± %6s ms    %s.%s"
     17                    % (
     18                        subtest["value"] / 1000.0,
     19                        subtest["value"] % 1000,
     20                        "%.3f" % (statistics.stdev(subtest["replicates"]) / 1000),
     21                        suite["name"],
     22                        subtest["name"],
     23                    )
     24                )