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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « psyco_win32/psyco/kdictproxy.py ('k') | psyco_win32/psyco/profiler.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: psyco_win32/psyco/logger.py
===================================================================
--- psyco_win32/psyco/logger.py (revision 0)
+++ psyco_win32/psyco/logger.py (revision 0)
@@ -0,0 +1,96 @@
+###########################################################################
+#
+# Psyco logger.
+# Copyright (C) 2001-2002 Armin Rigo et.al.
+
+"""Psyco logger.
+
+See log() in core.py.
+"""
+###########################################################################
+
+
+import _psyco
+from time import time, localtime, strftime
+
+
+current = None
+print_charges = 10
+dump_delay = 0.2
+dump_last = 0.0
+
+def write(s, level):
+ t = time()
+ f = t-int(t)
+ try:
+ current.write("%s.%02d %-*s%s\n" % (
+ strftime("%X", localtime(int(t))),
+ int(f*100.0), 63-level, s,
+ "%"*level))
+ current.flush()
+ except (OSError, IOError):
+ pass
+
+def psycowrite(s):
+ t = time()
+ f = t-int(t)
+ try:
+ current.write("%s.%02d %-*s%s\n" % (
+ strftime("%X", localtime(int(t))),
+ int(f*100.0), 60, s.strip(),
+ "% %"))
+ current.flush()
+ except (OSError, IOError):
+ pass
+
+##def writelines(lines, level=0):
+## if lines:
+## t = time()
+## f = t-int(t)
+## timedesc = strftime("%x %X", localtime(int(t)))
+## print >> current, "%s.%03d %-*s %s" % (
+## timedesc, int(f*1000),
+## 50-level, lines[0],
+## "+"*level)
+## timedesc = " " * (len(timedesc)+5)
+## for line in lines[1:]:
+## print >> current, timedesc, line
+
+def writememory():
+ write("memory usage: %d+ kb" % _psyco.memory(), 1)
+
+def dumpcharges():
+ global dump_last
+ if print_charges:
+ t = time()
+ if not (dump_last <= t < dump_last+dump_delay):
+ if t <= dump_last+1.5*dump_delay:
+ dump_last += dump_delay
+ else:
+ dump_last = t
+ #write("%s: charges:" % who, 0)
+ lst = _psyco.stattop(print_charges)
+ if lst:
+ f = t-int(t)
+ lines = ["%s.%02d ______\n" % (
+ strftime("%X", localtime(int(t))),
+ int(f*100.0))]
+ i = 1
+ for co, charge in lst:
+ detail = co.co_filename
+ if len(detail) > 19:
+ detail = '...' + detail[-17:]
+ lines.append(" #%-3d |%4.1f %%| %-26s%20s:%d\n" %
+ (i, charge*100.0, co.co_name, detail,
+ co.co_firstlineno))
+ i += 1
+ current.writelines(lines)
+ current.flush()
+
+def writefinalstats():
+ dumpcharges()
+ writememory()
+ writedate("program exit")
+
+def writedate(msg):
+ write('%s, %s' % (msg, strftime("%x")), 20)
Property changes on: psyco_win32\psyco\logger.py
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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