Giter Club home page Giter Club logo

hdr-plot's Introduction

hdr-plot for HdrHistogram

A standalone plotting script for https://github.com/giltene/wrk2 and https://github.com/HdrHistogram/HdrHistogram.

This is just a quick and unsophisticated script to quickly plot the HdrHistograms directly from the output of wkr2 benchmarks.

For example:

myplot.png

how to run

installation:

pip3 install --upgrade --user hdr-plot

usage:

usage: hdr_plot.py [-h] [--output OUTPUT] [--title TITLE] [--nosummary]
                   [--noversion] [--units UNITS]
                   [--percentiles-range-max PERCENTILES_RANGE_MAX]
                   [--summary-fields SUMMARY_FIELDS]
                   files [files ...]

Plot HDRHistogram latencies.

positional arguments:
  files                 List HDR files to plot

optional arguments:
  -h, --help            show this help message and exit
  --output OUTPUT       Output file name (default: latency.png)
  --title TITLE         The plot title
  --nosummary           Do not plot the summary box
  --noversion           Does not plot the version of hdr-plot
  --units UNITS         The latency units (ns, us, ms)
  --percentiles-range-max PERCENTILES_RANGE_MAX
                        The maximum value of the percentiles range, e.g.
                        99.9999 (i.e. how many nines to display)
  --summary-fields SUMMARY_FIELDS
                        List of fields to show in the summary box. A comma-
                        separated list of: min, max, mean, median, p50, p90,
                        p99, p999, p9999, ..., p999999. Default:
                        median,p999,p9999,max

Then run wrk with the -L option and store the output into a file, like:

wrk -t2 -c100 -d30s -R2000 -L http://127.0.0.1:8080/index.html &> result.out

Finally plot the percentile distribution:

hdr-plot --output myplot.png --title "My plot" ./result.out [...]

You can provide more files to be plotted on the same graph:

hdr-plot --output myplot.png --title "My plot" ./sample/file1.out ./sample/file2.out ./sample/file3.out

Please note that the name of the file is used as label for the plot legend.

Acknowledgements

A special thank to @Manuelbernhardt for providing PRs for a lot of improvements!

License

Copyright © 2018-2023 Bruno Bonacci - Distributed under the Apache License v 2.0

hdr-plot's People

Contributors

brunobonacci avatar manuelbernhardt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hdr-plot's Issues

Exception when input does not have percentile at exactly 0.5

My input data does not have a percentile at exactly 0.5. It was at 0.52 for some reasons.

Traceback (most recent call last):
  File ".venv/bin/hdr-plot", line 18, in <module>
    plot.main()
  File "/opt/intel/flexran/dpdk/vmwaretools/.venv/lib/python3.7/site-packages/hdr_plot/hdr_plot.py", line 110, in main
    plot_summarybox(ax, pct_data, labels)
  File "/opt/intel/flexran/dpdk/vmwaretools/.venv/lib/python3.7/site-packages/hdr_plot/hdr_plot.py", line 60, in plot_summarybox
       Value     Percentile TotalCount 1/(1-Percentile)

        0.00 0.000000000000         19           1.00
       59.00 0.100000000000      15609           1.11
       76.00 0.190000000000      29483           1.23
       83.00 0.271000000000      41776           1.37
       86.00 0.343900000000      56308           1.52
       87.00 0.409510000000      62278           1.69
       89.00 0.468559000000      74214           1.88
       90.00 0.521703100000      79637           2.09
       92.00 0.569532790000      89321           2.32
       93.00 0.612579511000      94175           2.58
... (rest of the file)

    textstr = '\n'.join([info_text(labels[i], percentiles[i]) for i in range(len(labels))])
  File "/opt/intel/flexran/dpdk/vmwaretools/.venv/lib/python3.7/site-packages/hdr_plot/hdr_plot.py", line 60, in <listcomp>
    textstr = '\n'.join([info_text(labels[i], percentiles[i]) for i in range(len(labels))])
  File "/opt/intel/flexran/dpdk/vmwaretools/.venv/lib/python3.7/site-packages/hdr_plot/hdr_plot.py", line 46, in info_text
    "max",    data['Latency'].max())
  File "/opt/intel/flexran/dpdk/vmwaretools/.venv/lib/python3.7/site-packages/pandas/core/series.py", line 139, in wrapper
    raise TypeError(f"cannot convert the series to {converter}")
TypeError: cannot convert the series to <class 'float'>

Offending line is the median calculation:

def info_text(name, data):
    textstr = '%-18s\n------------------\n%-6s = %6.2f ms\n%-6s = %6.2f ms\n%-6s = %6.2f ms\n'%(
        name,
        "min",    data['Latency'].min(),
        "median", data[data["Percentile"] == 0.5]["Latency"],
        "max",    data['Latency'].max())
    return textstr

I don't know why we're trying to calculate this manually but simply calling the median function fixes the problem.

def info_text(name, data):
    textstr = '%-18s\n------------------\n%-6s = %6.2f ms\n%-6s = %6.2f ms\n%-6s
 = %6.2f ms\n'%(
        name,
        "min",    data['Latency'].min(),
        "median", data['Latency'].median(),
        "max",    data['Latency'].max())
    return textstr

More sophisticated label name mechanism

Thank you for this script, it surely makes life easier :)
When used with several files, displaying the correct label is a bit of a heuristic process, though. I could rename my files, but generally, perhaps it could be improved
What do you think about the following heuristic for labeling:

  • split file names on a set of strings such as ., _, -
  • count the occurrences in each bin in the split (we care about 1 vs. many)
  • many bins are selected for label names
  • 1 bins (common for all) can become the title

I wouldn't mind PRing this

Thanks

Percentile filter

Hi, thank you for great tool.

Is there any way to filter out high percentiles?

Due to the high value for tail percentiles (99.9, 99.99....), I hardly see normal values. So if I can get a functionality to skip such an extreme case, I think it's more valuable as visualizer.

I'm not familiar with pandas/matplot, but if you give me some hint I will happily change it on my own.

Thanks :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.