Fixed plotting bug when all samples' measurements have the same value #832
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes #720.
Overview of the bug
Criterion
panics
when generating PDF plots withgnuplot
orplotters
and all measurements in a sample have the same duration.Root cause
NaN
) in the KDE's probability density estimation ((... / h)
whenh==0
)assertion failed: slice.len() > 1 && slice.iter().all(|x| !x.is_nan())
when initializing a Sample.When does it happen?
There are mainly 3 scenarios in which all samples have the same duration:
gnuplot
bug may fail criterion panicking withslice.len() > 1 && slice.iter().all(|x| !x.is_nan())
#720.iter_custom
benchmark (for example, when the having a custom logic that sets a minimum value for the duration to be, useful when comparing O(1) and O(n) functions).Changes
This PR fixes the root cause of the bug and slightly improves the plotting of PDF charts when all measurements in a sample have the same value.
Gnuplot:Can't plot with an empty x range!
7cf32ebBefore:
After: