-
Notifications
You must be signed in to change notification settings - Fork 1
/
Benchmark.py
48 lines (38 loc) · 1.08 KB
/
Benchmark.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/python
import os
import re
import sys
import getopt
import subprocess
import time
import tempfile
from subprocess import DEVNULL
from subprocess import check_output
def round_fps(fps):
return round(float(fps), 2)
##
# Base class for all benchmarks.
##
class Benchmark:
def __init__(self, name):
self.name = name
self.num_results = 1
def run_process(self, cmd, stdout = DEVNULL, stderr = DEVNULL):
process = subprocess.Popen(cmd, stderr=stderr, stdout=stdout)
process.wait()
return process
def get_latest_file(self, path):
files = os.listdir(path)
paths = [os.path.join(path, basename) for basename in files]
return max(paths, key=os.path.getctime)
def skip_first_run(self):
return True
def get_num_results(self):
return self.num_results
def get_name(self):
return self.name
class SteamBenchmark(Benchmark):
def __init__(self, name):
Benchmark.__init__(self, name)
assert('STEAM_DIR' in os.environ)
self._steam_dir = os.environ['STEAM_DIR']