-
Notifications
You must be signed in to change notification settings - Fork 1
/
benchmarkgenerator.py
executable file
·88 lines (58 loc) · 2.45 KB
/
benchmarkgenerator.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python -tt
"""
MAME support program to generate emulation benchmarks of a single game or a list of games:
- User is asked to enter a benchmark timeperiod (default is 60 secs)
- Benchmarks are generated and saved in a dedicated MAME benchmarks directory.
Usage:
1) Change configsetup.py according to your system setup.
2) To process a single game, type:
./benchmarkgenerator.py {game}
where {game} is the romname of the game (e.g. pacman)
OR to process all games in your Attract-Mode MAME romlist, type:
./benchmarkgenerator.py all
Author: Gordon Lim
Last Edit: 1 Feb 2018
"""
import configsetup
import os
import subprocess
import sys
def generatebenchmark(game, benchmarktimeperiod):
print("--- Generate new MAME benchmark file for {}...".format(game))
# Generate new MAME speed benchmark:
command = ["./mame64", "-str", benchmarktimeperiod, game]
benchmarkfile = open(MAMEbenchmarkdir + game + "_lastgame.log", "w")
subprocess.call(command, cwd = configsetup.MAMEexecdir, stdout = benchmarkfile)
benchmarkfile.close()
print("------ New MAME benchmark file for {} generated!".format(game))
return 0
def main():
# Setup configuration:
configsetup.init()
global MAMEbenchmarkdir
MAMEbenchmarkdir = configsetup.MAMEconfigdir + "benchmarks/"
if not os.path.isdir(MAMEbenchmarkdir):
subprocess.call(["mkdir", "benchmarks"], cwd = configsetup.MAMEconfigdir)
if not os.path.isdir(MAMEbenchmarkdir):
print("ERROR: MAME benchmark directory does not exist - EXIT")
return 1
# Check input and process game(s):
if (len(sys.argv) != 2):
print("Please provide a romname or 'all' as input argument")
return 1
inputargument = sys.argv[1]
benchmarktimeperiod = raw_input('Enter benchmark running time in seconds (default: 60 secs) and press return/enter: ') or '60'
if (inputargument == 'all'):
# Transform AM romlist into list of games:
games, header = configsetup.create_list_of_games_from_romlist()
if (len(games) == 0):
print("AM romlist is empty - EXIT")
return 1
# Create MAME benchmark file for each game:
for game in games:
generatebenchmark(game[0], benchmarktimeperiod)
else:
generatebenchmark(inputargument, benchmarktimeperiod)
return 0
if __name__ == '__main__':
main()