From 927c5ccc546aa8e8b2e3023f2dc7b431c0b634ea Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 2 May 2013 17:47:20 +0530 Subject: [PATCH] Print out profiling info when executing builtins.py --- src/calibre/customize/builtins.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index a60b69bf18..54f4e52f8c 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1727,6 +1727,28 @@ plugins += [ if __name__ == '__main__': # Test load speed import subprocess, textwrap + try: + subprocess.check_call(['python', '-c', textwrap.dedent( + ''' + import init_calibre # noqa + + def doit(): + import calibre.customize.builtins as b # noqa + + def show_stats(): + from pstats import Stats + s = Stats('/tmp/calibre_stats') + s.sort_stats('cumulative') + s.print_stats(30) + + import cProfile + cProfile.run('doit()', '/tmp/calibre_stats') + show_stats() + + ''' + )]) + except subprocess.CalledProcessError: + raise SystemExit(1) try: subprocess.check_call(['python', '-c', textwrap.dedent( '''