From 29fdf5d7648580890d89c8a48bbd6b94726060c3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2010 23:32:53 +0900 Subject: [PATCH] Added debug function timer. --- jblite/jmdict_proto2.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jblite/jmdict_proto2.py b/jblite/jmdict_proto2.py index b2df766..620b98d 100644 --- a/jblite/jmdict_proto2.py +++ b/jblite/jmdict_proto2.py @@ -1,7 +1,7 @@ from __future__ import print_function from __future__ import with_statement -import os, sys, re, sqlite3 +import os, sys, re, sqlite3, time from cStringIO import StringIO from xml.etree.cElementTree import ElementTree from helpers import gzread @@ -12,6 +12,16 @@ import gettext gettext.install("jblite") + +def do_time(fn, *args, **kwargs): + """Wraps a function call and prints the result.""" + start = time.time() + result = fn(*args, **kwargs) + end = time.time() + print("do_time: Fn=%s, Time=%f" % (repr(fn), end-start)) + return result + + class Database(object): """Top level object for SQLite 3-based JMdict database.""" -- 2.11.4.GIT