File: profile_docutils.py

package info (click to toggle)
python-docutils 0.19%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,668 kB
  • sloc: python: 45,630; lisp: 14,475; xml: 1,789; javascript: 1,032; sh: 130; makefile: 104
file content (39 lines) | stat: -rwxr-xr-x 927 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python3 -i

# $Id: profile_docutils.py 8925 2022-01-03 23:48:58Z milde $
# Author: Lea Wiemann <LeWiemann@gmail.com>
# Copyright: This script has been placed in the public domain.

import os.path
import docutils.core
import hotshot.stats

print('Profiler started.')

os.chdir(os.path.join(os.path.dirname(docutils.__file__), '..'))

print('Profiling...')

prof = hotshot.Profile('docutils.prof')
prof.runcall(docutils.core.publish_file, source_path='HISTORY.txt',
             destination_path='prof.HISTORY.html', writer_name='html')
prof.close()

print('Loading statistics...')

print("""
stats = hotshot.stats.load('docutils.prof')
stats.strip_dirs()
stats.sort_stats('time')  # 'cumulative'; 'calls'
stats.print_stats(40)
""")

stats = hotshot.stats.load('docutils.prof')
stats.strip_dirs()
stats.sort_stats('time')
stats.print_stats(40)

try:
    exec(open(os.environ['PYTHONSTARTUP']).read())
except:
    pass