easy_install benchmarker.py
and let me know if it installs for you? If it installs, here's a simple script to use it and see if it works... this script is a pretty thin usage of the package but proves it works in a basic sense:
>>> import bench
>>> from bench.benchmarker import benchmark
>>> @benchmark()
... def time_me():
... for _ in range(100):
... pass
...
>>> time_me()
>>> bench.benchmarker.print_stats()
Sat May 7 22:06:06 2011 /tmp/tmp.pstats
300 function calls in 0.002 CPU seconds
Random listing order was used
ncalls tottime percall cumtime percall filename:lineno(function)
100 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
100 0.001 0.000 0.002 0.000
100 0.001 0.000 0.001 0.000 {range}
Thanks!
-Tennessee
10 comments:
Nope. Does not work.
Searching for benchmarker.py
Reading http://pypi.python.org/simple/benchmarker.py/
Page at http://pypi.python.org/simple/benchmarker.py/ links to .py file(s) without version info; an index scan is required.
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
Reading https://bitbucket.org/tleeuwenburg/benchmarker.py
Reading https://bitbucket.org/tleeuwenburg/benchmarker.py/downloads
Best match: benchmarker.py 0.1
Downloading http://pypi.python.org/packages/source/b/benchmarker.py/benchmarker.py-0.1.tar.gz#md5=257fdf8a13b7d99b549745feb686dca3
Processing benchmarker.py-0.1.tar.gz
Running benchmarker.py-0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-EHfeTy/benchmarker.py-0.1/egg-dist-tmp-O2Zz1x
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/Current/bin/easy_install", line 8, in
load_entry_point('setuptools==0.7a1dev-r85380', 'console_scripts', 'easy_install')()
File "build/bdist.macosx-10.3-fat/egg/setuptools/command/easy_install.py", line 1712, in main
File "build/bdist.macosx-10.3-fat/egg/setuptools/command/easy_install.py", line 1700, in with_ei_usage
File "build/bdist.macosx-10.3-fat/egg/setuptools/command/easy_install.py", line 1716, in
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "build/bdist.macosx-10.3-fat/egg/setuptools/command/easy_install.py", line 211, in run
File "build/bdist.macosx-10.3-fat/egg/setuptools/command/easy_install.py", line 446, in easy_install
File "build/bdist.macosx-10.3-fat/egg/setuptools/command/easy_install.py", line 476, in install_item
File "build/bdist.macosx-10.3-fat/egg/setuptools/command/easy_install.py", line 655, in install_eggs
File "build/bdist.macosx-10.3-fat/egg/setuptools/command/easy_install.py", line 930, in build_and_install
File "build/bdist.macosx-10.3-fat/egg/setuptools/command/easy_install.py", line 919, in run_setup
File "build/bdist.macosx-10.3-fat/egg/setuptools/sandbox.py", line 62, in run_setup
File "build/bdist.macosx-10.3-fat/egg/setuptools/sandbox.py", line 105, in run
File "build/bdist.macosx-10.3-fat/egg/setuptools/sandbox.py", line 64, in
File "setup.py", line 6, in
File "/tmp/easy_install-EHfeTy/benchmarker.py-0.1/bench/__init__.py", line 16, in
File "/tmp/easy_install-EHfeTy/benchmarker.py-0.1/bench/benchmarker.py", line 25, in
ImportError: No module named decorator
Exit 1
Thanks to both of you... the setup file is supposed to register the dependency and install it automatically, however I must not be correctly specifying it. I'll post back when it is fixed.
Thanks,
-T
Okay, fixed now. Sorry for installation breakage.
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bench
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.6/dist-packages/benchmarker.py-0.22-py2.6.egg/bench/__init__.py", line 16, in
import benchmarker
File "/usr/local/lib/python2.6/dist-packages/benchmarker.py-0.22-py2.6.egg/bench/benchmarker.py", line 18, in
import pstats
ImportError: No module named pstats
Installed fine. In the last statement got an error:
>>> bench.benchmarker.print_stats()
Traceback (most recent call last):
File "", line 1, in
File "build\bdist.win32\egg\bench\benchmarker.py", line 249, in print_stats
File "c:\python27\lib\pstats.py", line 93, in __init__
self.init(arg)
File "c:\python27\lib\pstats.py", line 107, in init
self.load_stats(arg)
File "c:\python27\lib\pstats.py", line 121, in load_stats
f = open(arg, 'rb')
IOError: [Errno 2] No such file or directory: 'c:\\users\\dorai\\appdata\\local\
\temp/tmp.pstats'
Will create a temp directory and retry.
Had to install the ubuntu package python-profiler for pstats.
Then i got the following error:
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bench
>>> from bench.benchmarker import benchmark
>>> @benchmark()
... def time_me():
... for i in range(1111):
... pass
...
>>> time_me()
>>> bench.benchmarker.print_stats()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/benchmarker.py-0.22-py2.7.egg/bench/benchmarker.py", line 249, in print_stats
stats = pstats.Stats(LOGFILE_NAME)
File "/usr/lib/python2.7/pstats.py", line 93, in __init__
self.init(arg)
File "/usr/lib/python2.7/pstats.py", line 107, in init
self.load_stats(arg)
File "/usr/lib/python2.7/pstats.py", line 121, in load_stats
f = open(arg, 'rb')
IOError: [Errno 2] No such file or directory: '/tmp/tmp.pstats'
Note that "easy_install" is long ago deprecated, and that you should get cleaner and more consistent results going forward by switching to "pip install", which comes standard with all modern virtualenv installations. :)
That's interesting that it's failing... I'll keep looking. I really appreciate the help finding and ironing out the bugs.
Good tip re using pip instead of easy_install. I guess I wasn't sure what the right thing to use was, so I went with what I've used before. But perhaps pip is more with the times :)
Hi all,
Thanks very much for the comments. I believe I have fixed all the issues found so far.
Even i encountered such an issue once.Its good to fix such hurdles.
Post a Comment