tor-browser

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

benchmark_server.py (1665B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 from __future__ import print_function
      6 import json
      7 import os
      8 import subprocess
      9 import time
     10 import urllib2
     11 
     12 FILE = 'perf.json'
     13 URL = 'https://wrperf.org/submit'
     14 
     15 while True:
     16    try:
     17        # Remove any previous results
     18        try:
     19            os.remove(FILE)
     20        except Exception:
     21            pass
     22 
     23        # Pull latest code
     24        subprocess.call(["git", "pull"])
     25 
     26        # Get the git revision of this build
     27        revision = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
     28 
     29        # Build
     30        subprocess.call(["cargo", "build", "--release"])
     31 
     32        # Run benchmarks
     33        env = os.environ.copy()
     34        # Ensure that vsync is disabled, to get meaningful 'composite' times.
     35        env['vblank_mode'] = '0'
     36        subprocess.call(["cargo", "run", "--release", "--", "perf", FILE], env=env)
     37 
     38        # Read the results
     39        with open(FILE) as file:
     40            results = json.load(file)
     41 
     42        # Post the results to server
     43        payload = {
     44            'key': env['WEBRENDER_PERF_KEY'],
     45            'revision': revision,
     46            'timestamp': str(time.time()),
     47            'tests': results['tests'],
     48        }
     49 
     50        req = urllib2.Request(URL,
     51                              headers={"Content-Type": "application/json"},
     52                              data=json.dumps(payload))
     53 
     54        f = urllib2.urlopen(req)
     55    except Exception as e:
     56        print(e)
     57 
     58    # Delay a bit until next benchmark
     59    time.sleep(60 * 60)