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__ )))
73import sc2reader
84
9- skipnames = ('empty' ,'footman' )
10-
115def 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.
2711def benchmark_with_timetime ():
@@ -31,10 +15,11 @@ def benchmark_with_timetime():
3115 print diff
3216
3317def 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