Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percentile Support #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Percentile Support #93

wants to merge 2 commits into from

Conversation

jdhardy
Copy link

@jdhardy jdhardy commented Nov 8, 2017

Fix #92 by adding support for calculating & displaying arbitrary percentiles, by using --benchmark-columns=p99.9. Only requested percentile columns are calculated and displayed. They are also preserved in CSV and JSON output formats if they are requested.

Had some issues running tox tests, but the core variants all passed.

Calculate interpolted percentiles using the NIST method. This ensures
that p0 == min, p50 == median, p100 == max.
To show percentile columns, use --benchmark-columns=p99.9.

Requested columns are added to the flattened output dict for display.
Percentile columns are only calculated and shown if requested. Cache
perecntile results to avoid recalculation. Add usage note to
documentation.
@jdhardy
Copy link
Author

jdhardy commented Nov 8, 2017

Here's what the output looks like with --benchmark-columns=Min,Median,P99.9,Max,Ops:

================================================= test session starts ==================================================
platform darwin -- Python 3.6.3, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
benchmark: 3.1.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /.../tests/perf, inifile: pytest-perf.ini
plugins: cov-2.5.1, benchmark-3.1.1
collected 3 items

tests/perf/test_Perf.py ...


-------------------------------------------- benchmark 'test_benchmark': 3 tests ---------------------------------------------
Name (time in ms)                  Min             Median               P99.9                 Max                OPS
------------------------------------------------------------------------------------------------------------------------------
benchmark[2000-xxxxxxxx]        9.0091 (1.0)      11.9048 (1.0)       43.1680 (1.0)       43.1680 (1.0)      78.7381 (1.0)
benchmark[200-xxxxxxxx]        11.8196 (1.31)     12.3910 (1.04)     401.4592 (9.30)     401.4592 (9.30)     47.8764 (0.61)
benchmark[200000-xxxxxxxx]     33.7439 (3.75)     37.7569 (3.17)      74.0722 (1.72)      74.0722 (1.72)     25.5273 (0.32)
------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
============================================== 3 passed in 14.32 seconds ===============================================

@ionelmc
Copy link
Owner

ionelmc commented Nov 10, 2017

This looks pretty good. I still need to look over the code a bit but there is one thing that makes me a bit wary: the fact that the pXX.X column only gets in the saved data if it's active in the display (via --benchmark-columns).

This would be a problem if the user doesn't save the data (via either --benchmark-save-data or --benchmark-columns=pXX.X) and then tries to look at previous run data with a new or different pXX.X. This is basically my fault here, I shouldn't have implemented --benchmark-save-data (the include_data in the internals) so I wonder if it's time to remove it, always include full data and just let users live the few MBs of json ...

@ionelmc
Copy link
Owner

ionelmc commented Nov 10, 2017

I would love to hear some opinions on this problem.

@jdhardy
Copy link
Author

jdhardy commented Nov 30, 2017

Storing the percentiles was one part I wasn't sure about. Perhaps a new --benchmark-save-columns option for those that don't want to/can't store all data?

@ionelmc
Copy link
Owner

ionelmc commented Feb 8, 2018

So I've been thinking about this again, and I want this feature. But I was these stats to be always saved.

@jdhardy Would you think people would ever want anything else besides p90, p95, p99, p99.9 and p99.99?

@jdhardy
Copy link
Author

jdhardy commented Feb 8, 2018 via email

@ionelmc
Copy link
Owner

ionelmc commented Aug 17, 2018

Oh damn it's almost a year.

So now I'm thinking about a compromise ... eg, always compute p90, p95, p99, p99.9 and p99.99 and compute and store on demand anything else. Tho it doesn't seem like anyone wants anything else other than p90, p95, p99, p99.9 and p99.99, so just remove the on-demand thing? What do you think @jdhardy? (just asking for opinion, not pr rework)

@jdhardy
Copy link
Author

jdhardy commented Aug 28, 2018

I'm actually (finally) circling back on this in the next week or two. I'm fine with always doing p90/95/99/99.9/99.99 to start with and then seeing if anyone wants anything else. That should cover the vast majority of use cases.

@ionelmc ionelmc added this to the v3.2.0 milestone Jan 3, 2019
@ionelmc
Copy link
Owner

ionelmc commented Jan 3, 2019

@jdhardy hey, you still wanna work on this?

@jdhardy
Copy link
Author

jdhardy commented Jan 4, 2019 via email

@ionelmc ionelmc modified the milestones: v3.2.0, v3.3.0 Jan 7, 2019
@jdhardy
Copy link
Author

jdhardy commented Feb 4, 2020

Yikes. I haven't had a chance to look at this for a while, and probably won't for a while longer (I'm no longer working on that project). Feel free to close it, and apologies for not being able to follow through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Percentiles
2 participants