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

Unified Diff: third_party/psyco_win32/psyco/logger.py

Issue 6778017: Add use of Psyco to GYP on Windows. On my z600 with 12 GB of RAM, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for non-Windows platforms. 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
Index: third_party/psyco_win32/psyco/logger.py
diff --git a/third_party/psyco_win32/psyco/logger.py b/third_party/psyco_win32/psyco/logger.py
new file mode 100644
index 0000000000000000000000000000000000000000..dac53b7b59c1c650ace4c6f6737a1cb94665ba74
--- /dev/null
+++ b/third_party/psyco_win32/psyco/logger.py
@@ -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)

Powered by Google App Engine
This is Rietveld 408576698