bg
[sso] / shaken_and_spit_out / pgfw / Profile.py
1 import cProfile
2 from time import strftime
3 from os import mkdir
4 from os.path import join, exists
5
6 from GameChild import GameChild
7
8 class Profile(cProfile.Profile, GameChild):
9
10 def __init__(self, parent):
11 GameChild.__init__(self, parent)
12 cProfile.Profile.__init__(self)
13 if self.requested():
14 self.enable()
15
16 def requested(self):
17 return self.check_command_line("p")
18
19 def end(self):
20 if self.requested():
21 root = "stat/"
22 if not exists(root):
23 mkdir(root)
24 self.disable()
25 self.create_stats()
26 self.dump_stats(join(root, strftime("%Y%m%d-%H%M_%S.stat")))