Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: psyco_win32/psyco/logger.py

Issue 6777021: Adding Win32 installation of Psyco. This will be used to speed up GYP, adding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « psyco_win32/psyco/kdictproxy.py ('k') | psyco_win32/psyco/profiler.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 ###########################################################################
2 #
3 # Psyco logger.
4 # Copyright (C) 2001-2002 Armin Rigo et.al.
5
6 """Psyco logger.
7
8 See log() in core.py.
9 """
10 ###########################################################################
11
12
13 import _psyco
14 from time import time, localtime, strftime
15
16
17 current = None
18 print_charges = 10
19 dump_delay = 0.2
20 dump_last = 0.0
21
22 def write(s, level):
23 t = time()
24 f = t-int(t)
25 try:
26 current.write("%s.%02d %-*s%s\n" % (
27 strftime("%X", localtime(int(t))),
28 int(f*100.0), 63-level, s,
29 "%"*level))
30 current.flush()
31 except (OSError, IOError):
32 pass
33
34 def psycowrite(s):
35 t = time()
36 f = t-int(t)
37 try:
38 current.write("%s.%02d %-*s%s\n" % (
39 strftime("%X", localtime(int(t))),
40 int(f*100.0), 60, s.strip(),
41 "% %"))
42 current.flush()
43 except (OSError, IOError):
44 pass
45
46 ##def writelines(lines, level=0):
47 ## if lines:
48 ## t = time()
49 ## f = t-int(t)
50 ## timedesc = strftime("%x %X", localtime(int(t)))
51 ## print >> current, "%s.%03d %-*s %s" % (
52 ## timedesc, int(f*1000),
53 ## 50-level, lines[0],
54 ## "+"*level)
55 ## timedesc = " " * (len(timedesc)+5)
56 ## for line in lines[1:]:
57 ## print >> current, timedesc, line
58
59 def writememory():
60 write("memory usage: %d+ kb" % _psyco.memory(), 1)
61
62 def dumpcharges():
63 global dump_last
64 if print_charges:
65 t = time()
66 if not (dump_last <= t < dump_last+dump_delay):
67 if t <= dump_last+1.5*dump_delay:
68 dump_last += dump_delay
69 else:
70 dump_last = t
71 #write("%s: charges:" % who, 0)
72 lst = _psyco.stattop(print_charges)
73 if lst:
74 f = t-int(t)
75 lines = ["%s.%02d ______\n" % (
76 strftime("%X", localtime(int(t))),
77 int(f*100.0))]
78 i = 1
79 for co, charge in lst:
80 detail = co.co_filename
81 if len(detail) > 19:
82 detail = '...' + detail[-17:]
83 lines.append(" #%-3d |%4.1f %%| %-26s%20s:%d\n" %
84 (i, charge*100.0, co.co_name, detail,
85 co.co_firstlineno))
86 i += 1
87 current.writelines(lines)
88 current.flush()
89
90 def writefinalstats():
91 dumpcharges()
92 writememory()
93 writedate("program exit")
94
95 def writedate(msg):
96 write('%s, %s' % (msg, strftime("%x")), 20)
OLDNEW
« no previous file with comments | « psyco_win32/psyco/kdictproxy.py ('k') | psyco_win32/psyco/profiler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698