Skip to content

Commit

Permalink
profiled demo added
Browse files Browse the repository at this point in the history
  • Loading branch information
lig committed Dec 24, 2008
1 parent 4254b22 commit 1ca5c4e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
9 changes: 6 additions & 3 deletions examples/demo.py
Expand Up @@ -28,9 +28,12 @@
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
try:
from pystardict import Dictionary
except ImportError:
print Exception('No pystardict in PYTHONPATH. Try --local parameter.')
exit(1)
except ImportError, e:
if __name__ == '__main__':
print Exception('No pystardict in PYTHONPATH. Try --local parameter.')
exit(1)
else:
raise e

def demo():

Expand Down
31 changes: 31 additions & 0 deletions examples/profile_demo.py
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
"""
Copyright 2008 Serge Matveenko
This file is part of PyStarDict.
PyStarDict is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PyStarDict is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PyStarDict. If not, see <http://www.gnu.org/licenses/>.
@author: Serge Matveenko <s@matveenko.ru>
"""
import cProfile
import os
import sys

"""hack in local sources"""
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
from demo import demo

if __name__ == '__main__':
cProfile.run('demo()')

0 comments on commit 1ca5c4e

Please sign in to comment.