| Message ID | 20261105090156.527585-1-barnabas.pocze@ideasonboard.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Quoting Barnabás Pőcze (2026-11-05 09:01:55) > Empty histograms are usually of little use, so add a function that checks > if the histogram contains any data points. > > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > src/ipa/libipa/histogram.cpp | 10 ++++++++++ > src/ipa/libipa/histogram.h | 1 + > 2 files changed, 11 insertions(+) > > diff --git a/src/ipa/libipa/histogram.cpp b/src/ipa/libipa/histogram.cpp > index 9e46a05a90..c516ace7da 100644 > --- a/src/ipa/libipa/histogram.cpp > +++ b/src/ipa/libipa/histogram.cpp > @@ -74,6 +74,16 @@ Histogram::Histogram(std::span<const uint32_t> data) > * \return Number of values > */ > > +/** > + * \fn Histogram::empty() > + * \brief Determine if the histogram is empty > + * > + * An empty histogram is one which has only empty bins, > + * that is, bins with a count of 0. > + * > + * \return True if the histogram is empty > + */ > + > /** > * \fn Histogram::operator[](size_t bin) const > * \brief Retrieve the value for \a bin > diff --git a/src/ipa/libipa/histogram.h b/src/ipa/libipa/histogram.h > index b50868ab4d..cbc34e8c70 100644 > --- a/src/ipa/libipa/histogram.h > +++ b/src/ipa/libipa/histogram.h > @@ -41,6 +41,7 @@ public: > uint64_t cumulativeFrequency(double bin) const; > double quantile(double q, uint32_t first = 0, uint32_t last = UINT_MAX) const; > double interQuantileMean(double lowQuantile, double hiQuantile) const; > + bool empty() const { return total() == 0; } > > uint32_t operator[](size_t bin) const > { > -- > 2.56.0 >
diff --git a/src/ipa/libipa/histogram.cpp b/src/ipa/libipa/histogram.cpp index 9e46a05a90..c516ace7da 100644 --- a/src/ipa/libipa/histogram.cpp +++ b/src/ipa/libipa/histogram.cpp @@ -74,6 +74,16 @@ Histogram::Histogram(std::span<const uint32_t> data) * \return Number of values */ +/** + * \fn Histogram::empty() + * \brief Determine if the histogram is empty + * + * An empty histogram is one which has only empty bins, + * that is, bins with a count of 0. + * + * \return True if the histogram is empty + */ + /** * \fn Histogram::operator[](size_t bin) const * \brief Retrieve the value for \a bin diff --git a/src/ipa/libipa/histogram.h b/src/ipa/libipa/histogram.h index b50868ab4d..cbc34e8c70 100644 --- a/src/ipa/libipa/histogram.h +++ b/src/ipa/libipa/histogram.h @@ -41,6 +41,7 @@ public: uint64_t cumulativeFrequency(double bin) const; double quantile(double q, uint32_t first = 0, uint32_t last = UINT_MAX) const; double interQuantileMean(double lowQuantile, double hiQuantile) const; + bool empty() const { return total() == 0; } uint32_t operator[](size_t bin) const {
Empty histograms are usually of little use, so add a function that checks if the histogram contains any data points. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- src/ipa/libipa/histogram.cpp | 10 ++++++++++ src/ipa/libipa/histogram.h | 1 + 2 files changed, 11 insertions(+)