pytest-benchmark icon indicating copy to clipboard operation
pytest-benchmark copied to clipboard

Allow reading config from tox.ini / setup.cfg?

Open aldanor opened this issue 8 years ago • 11 comments

Seeing as there's a growing list of options that barely fits one help screen, maybe it would make sense to think about reading the default from config file same as most other tools do (tox itself, coverage, pytest, all sorts of linters)?

So instead of passing a bajillion of command line arguments, you could just add a section in your tox.ini like so (just making these up):

[benchmark]
columns = min, max
precision = auto
report = term, json
json = foo.json

aldanor avatar Sep 14 '15 10:09 aldanor

Just for refference, the complete list of current options:

[benchmark]
autosave = false
calibration_precision = 10
compare =
compare_fail =
disable_gc = false
group_by = group
histogram =
json =
max_time = 1.0
min_rounds = 5
min_time = 0.000005
only = false
save =
save_data =
skip = false
sort = min
storage =
timer = time.perf_counter
verbose = false
warmup = false
warmup_iterations = 100000

And new options:

columns = min, max
precision = auto
report = term, json

ionelmc avatar Sep 14 '15 11:09 ionelmc

Whoah that's a lot of options, this definitely deserves a config file section!

aldanor avatar Sep 14 '15 11:09 aldanor

Maybe we should use some namespaces, eg:

[benchmark:report]
sort = min
compare = 
compare_fail = 

[benchmark:report:term]
class = mod.MyCustomRenderer
precision = auto
columns  = min, max

ionelmc avatar Sep 14 '15 11:09 ionelmc

+1

anarcat avatar Oct 06 '15 06:10 anarcat

Another idea is to use environment variables

ionelmc avatar Dec 31 '15 11:12 ionelmc

@ionelmc Haven't been using pytest-benchmark for quite a while, now the time has come again, I've searched for ways to configure it and... found my own ticket :)

Wondering if there are any news on this front, or help needed?

aldanor avatar Jun 10 '19 22:06 aldanor

@aldanor ah sorry I haven't done anything on this yet. Do you want to help with a PR?

ionelmc avatar Jun 11 '19 09:06 ionelmc

Yet another thought... pyproject.toml? (seeing as more and more libraries and projects are moving towards it these days)

aldanor avatar Dec 11 '19 16:12 aldanor

Worth checking out if tox/pytest will move to toml (there was some discussion about that but I forgot where) and just do what they do.

ionelmc avatar Jan 04 '20 09:01 ionelmc

I'm a little confused about whether there's currently some support for reading config from a file. E.g. https://github.com/ionelmc/pytest-benchmark/issues/27 and in the docs:

--benchmark-enable
   Forcibly enable benchmarks. Use this option to override –benchmark-disable (in case you have it in pytest configuration).

seem to indicate there's already a way to read from pytest configuration files since it's causally mentioned!?

matham avatar Dec 15 '20 21:12 matham

Look no further: https://docs.pytest.org/en/stable/customize.html (eg: addopts = --benchmark-something). Tho I don't think it's a good idea to have --benchmark-enable in the config file - you'd never be able to disable the benchmarks.

ionelmc avatar Dec 19 '20 14:12 ionelmc