Skip to content

Commit dd544d8

Browse files
committed
Updates profile.py to the new interfaces
1 parent ed9c52f commit dd544d8

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

profile.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
1-
import cProfile
2-
from pstats import Stats
3-
import time
1+
import cProfile, pstats, time
42

5-
import os,sys
6-
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
73
import sc2reader
84

9-
skipnames = ('empty','footman')
10-
115
def parse_replays():
126
# Run four times to dampen noise
137
for run in range(1,4):
14-
file_list = []
15-
rootdir = "test_replays/build17811/"
16-
for root, sub_folders, files in os.walk(rootdir):
17-
for file in files:
18-
basename, extension = os.path.splitext(file)
19-
if (basename not in skipnames and extension.lower() == ".sc2replay"):
20-
file_list.append(os.path.join(root,file))
21-
22-
for file in file_list:
23-
print file
24-
replay = sc2reader.read(file)
8+
sc2reader.read("test_replays/1.3.0.18092",verbose=True)
259

2610
# Use the results of this function when comparing performance with other libraries.
2711
def benchmark_with_timetime():
@@ -31,10 +15,11 @@ def benchmark_with_timetime():
3115
print diff
3216

3317
def profile():
34-
cProfile.run("parse_replays()","replay_profile")
35-
stats = Stats("replay_profile")
36-
stats.strip_dirs().sort_stats("time").print_stats(30)
18+
cProfile.run("parse_replays()","replay_profile2")
19+
stats = pStats.Stats("replay_profile")
20+
stats.strip_dirs().sort_stats("time").print_stats(30)
3721

3822

39-
#benchmark_with_timetime()
40-
profile()
23+
if __name__ == '__main__':
24+
#benchmark_with_timetime()
25+
profile()

0 commit comments

Comments
 (0)