-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathprofile.py
More file actions
40 lines (32 loc) · 1.11 KB
/
profile.py
File metadata and controls
40 lines (32 loc) · 1.11 KB
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
import cProfile
from pstats import Stats
import time
import os,sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import sc2reader
skipnames = ('empty','footman')
def parse_replays():
# Run four times to dampen noise
for run in range(1,4):
file_list = []
rootdir = "test_replays/build17811/"
for root, sub_folders, files in os.walk(rootdir):
for file in files:
basename, extension = os.path.splitext(file)
if (basename not in skipnames and extension.lower() == ".sc2replay"):
file_list.append(os.path.join(root,file))
for file in file_list:
print file
replay = sc2reader.read(file)
# Use the results of this function when comparing performance with other libraries.
def benchmark_with_timetime():
start = time.time()
parse_replays()
diff = time.time() - start
print diff
def profile():
cProfile.run("parse_replays()","replay_profile")
stats = Stats("replay_profile")
stats.strip_dirs().sort_stats("time").print_stats(30)
#benchmark_with_timetime()
profile()