stats->sorted = TRUE;
}
-uint64_t stats_dist_get_median(const struct stats_dist *stats)
+uint64_t stats_dist_get_median(struct stats_dist *stats)
{
if (stats->count == 0)
return 0;
/* cast-away const - reading requires sorting */
- stats_dist_ensure_sorted((struct stats_dist *)stats);
+ stats_dist_ensure_sorted(stats);
unsigned int count = (stats->count < stats->sample_count)
? stats->count
: stats->sample_count;
return idx;
}
-uint64_t stats_dist_get_percentile(const struct stats_dist *stats, double fraction)
+uint64_t stats_dist_get_percentile(struct stats_dist *stats, double fraction)
{
if (stats->count == 0)
return 0;
- /* cast-away const - reading requires sorting */
- stats_dist_ensure_sorted((struct stats_dist *)stats);
+ stats_dist_ensure_sorted(stats);
unsigned int count = (stats->count < stats->sample_count)
? stats->count
: stats->sample_count;
/* Returns events' average. */
double stats_dist_get_avg(const struct stats_dist *stats);
/* Returns events' approximate (through random subsampling) median. */
-uint64_t stats_dist_get_median(const struct stats_dist *stats);
+uint64_t stats_dist_get_median(struct stats_dist *stats);
/* Returns events' variance */
double stats_dist_get_variance(const struct stats_dist *stats);
/* Returns events' approximate (through random subsampling) percentile.
fraction parameter is in the range (0., 1.], so 95th %-ile is 0.95. */
-uint64_t stats_dist_get_percentile(const struct stats_dist *stats, double fraction);
+uint64_t stats_dist_get_percentile(struct stats_dist *stats, double fraction);
/* Returns events' approximate (through random subsampling) 95th percentile. */
-static inline uint64_t stats_dist_get_95th(const struct stats_dist *stats)
+static inline uint64_t stats_dist_get_95th(struct stats_dist *stats)
{
return stats_dist_get_percentile(stats, 0.95);
}
#define DBL_EQ(a, b) (fabs((a)-(b)) < 0.001)
static void
-test_stats_dist_verify(const struct stats_dist *t, const int64_t *input,
+test_stats_dist_verify(struct stats_dist *t, const int64_t *input,
unsigned int input_size)
{
uint64_t min = INT_MAX, max = 0, sum = 0;