Make tools/ compatible with both, Python 2 and 3 without 2to3-conversion.
[docutils.git] / tools / dev / profile_docutils.py
blobd31ba6fd00e42ed2aec705ec2764ae86002f397c
1 #!/usr/bin/python -i
3 # $Id$
4 # Author: Lea Wiemann <LeWiemann@gmail.com>
5 # Copyright: This script has been placed in the public domain.
7 import os.path
8 import docutils.core
9 import hotshot.stats
11 print('Profiler started.')
13 os.chdir(os.path.join(os.path.dirname(docutils.__file__), '..'))
15 print('Profiling...')
17 prof = hotshot.Profile('docutils.prof')
18 prof.runcall(docutils.core.publish_file, source_path='HISTORY.txt',
19 destination_path='prof.HISTORY.html', writer_name='html')
20 prof.close()
22 print('Loading statistics...')
24 print("""
25 stats = hotshot.stats.load('docutils.prof')
26 stats.strip_dirs()
27 stats.sort_stats('time') # 'cumulative'; 'calls'
28 stats.print_stats(40)
29 """)
31 stats = hotshot.stats.load('docutils.prof')
32 stats.strip_dirs()
33 stats.sort_stats('time')
34 stats.print_stats(40)
36 try:
37 exec(open(os.environ['PYTHONSTARTUP']).read())
38 except:
39 pass