]> git.lyx.org Git - lyx.git/blob - lib/lyx2lyx/profiling.py
This is LyX 2.2.0alpha1
[lyx.git] / lib / lyx2lyx / profiling.py
1 #! /usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2004 José Matos <jamatos@lyx.org>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
19 # We need all this because lyx2lyx does not have the .py termination
20 import imp
21 lyx2lyx = imp.load_source("lyx2lyx", "lyx2lyx", open("lyx2lyx"))
22
23 # Profiler used in the study
24 import hotshot, hotshot.stats
25
26 import sys
27 import os
28
29 """
30 This program profiles lyx2lyx.
31 Usage:
32         ./profiling.py option_to_lyx2lyx
33
34 Example:
35         ./profiling.py -ou.lyx ../doc/UserGuide.lyx
36 """
37
38 def main():
39     # This will only work with python >= 2.2, the version where this module was added
40     prof = hotshot.Profile("lyx2lyx.prof") # Use temporary file, here?
41     benchtime = prof.runcall(lyx2lyx.main)
42     prof.close()
43
44     # After the tests, show the profile analysis.
45     stats = hotshot.stats.load("lyx2lyx.prof")
46     stats.strip_dirs()
47     stats.sort_stats('time', 'calls')
48     stats.print_stats(20)
49
50     os.unlink("lyx2lyx.prof")
51
52
53 if __name__ == "__main__":
54     main()