ionelmc / pytest-benchmark

py.test fixture for benchmarking code
BSD 2-Clause "Simplified" License
1.25k stars 119 forks source link

plot histogram in one graph #53

Open yitang opened 8 years ago

yitang commented 8 years ago

Hi, thanks for writing this package. I just started use it and found some useful results. I wonder how could I plot histogram into one graph? Currently I have 4 svn files, one for each function.

Thanks.

ionelmc commented 8 years ago

It is possible with the master branch by using the new py.test-benchmark compare tool. Example result:

image 156

Let me know if you got issues.

yitang commented 8 years ago

exciting! I'd try today.

yitang commented 8 years ago

how do I use the py.test-benchmark compare tool? I tried to run

py.test --benchmark-json=results.json benchmark.py 
py.test-benchmark compare results.json

but got this error

Traceback (most recent call last):
  File "/usr/local/bin/py.test-benchmark", line 9, in <module>
    load_entry_point('pytest-benchmark==3.0.0', 'console_scripts', 'py.test-benchmark')()
  File "/usr/local/lib/python3.4/dist-packages/pytest_benchmark-3.0.0-py3.4.egg/pytest_benchmark/cli.py", line 159, in main
    groups = load(storage, args.glob_or_file, args.group_by)
  File "/usr/local/lib/python3.4/dist-packages/pytest_benchmark-3.0.0-py3.4.egg/pytest_benchmark/cli.py", line 141, in load
    config=None,
  File "/usr/local/lib/python3.4/dist-packages/pytest_benchmark-3.0.0-py3.4.egg/pytest_benchmark/plugin.py", line 270, in pytest_benchmark_group_stats
    for bench in benchmarks:
  File "/usr/local/lib/python3.4/dist-packages/pytest_benchmark-3.0.0-py3.4.egg/pytest_benchmark/storage.py", line 94, in load_benchmarks
    for path, data in self.load(*globs_or_files)
  File "/usr/local/lib/python3.4/dist-packages/pytest_benchmark-3.0.0-py3.4.egg/pytest_benchmark/storage.py", line 93, in <listcomp>
    (short_filename(path), path, data)
  File "/usr/local/lib/python3.4/dist-packages/pytest_benchmark-3.0.0-py3.4.egg/pytest_benchmark/storage.py", line 76, in load
    for file in self.query(*globs_or_files):
  File "/usr/local/lib/python3.4/dist-packages/pytest_benchmark-3.0.0-py3.4.egg/pytest_benchmark/storage.py", line 71, in query
    file for file in self.path.glob(filename_glob)
UnboundLocalError: local variable 'filename_glob' referenced before assignment
ionelmc commented 8 years ago

Hmm, that looks like a bug. The compare tool is meant to be used with the .benchmarks directory (eg: save with --benchmark-save or --benchmark-autosave). Try that meanwhile I look at this bug.