summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-03-23 11:19:14 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2013-04-02 08:39:05 +0100
commit0446fae26d35dc4e31aadc498f0f9b48b21d2c45 (patch)
tree34e62f5438f9787d9450a8f1f1977494707fb111
parentfdec6b37596d8b064ff082326d7189daa8208052 (diff)
perf: Iteratively prune outliers
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--perf/cairo-stats.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/perf/cairo-stats.c b/perf/cairo-stats.c
index 44ed038c..7a36a138 100644
--- a/perf/cairo-stats.c
+++ b/perf/cairo-stats.c
@@ -56,37 +56,42 @@ _cairo_stats_compute (cairo_stats_t *stats,
* and third quartiles and IQR is the inter-quartile range (Q3 -
* Q1).
*/
- qsort (values, num_values, sizeof (cairo_time_t), _cairo_time_cmp);
+ num_valid = num_values;
+ do {
+ num_values = num_valid;
+ qsort (values, num_values, sizeof (cairo_time_t), _cairo_time_cmp);
- q1 = values[1*num_values/4];
- q3 = values[3*num_values/4];
+ q1 = values[1*num_values/4];
+ q3 = values[3*num_values/4];
- /* XXX assumes we have native uint64_t */
- iqr = q3 - q1;
- outlier_min = q1 - 3 * iqr / 2;
- outlier_max = q3 + 3 * iqr / 2;
+ /* XXX assumes we have native uint64_t */
+ iqr = q3 - q1;
+ outlier_min = q1 - 3 * iqr / 2;
+ outlier_max = q3 + 3 * iqr / 2;
- for (i = 0; i < num_values && values[i] < outlier_min; i++)
- ;
- min_valid = i;
+ for (i = 0; i < num_values && values[i] < outlier_min; i++)
+ ;
+ min_valid = i;
- for (i = 0; i < num_values && values[i] <= outlier_max; i++)
- ;
- num_valid = i - min_valid;
- assert(num_valid);
+ for (i = 0; i < num_values && values[i] <= outlier_max; i++)
+ ;
+ num_valid = i - min_valid;
+ assert(num_valid);
+ values += min_valid;
+ } while (num_valid != num_values);
stats->iterations = num_valid;
- stats->min_ticks = values[min_valid];
- stats->median_ticks = values[min_valid + num_valid / 2];
+ stats->min_ticks = values[0];
+ stats->median_ticks = values[num_valid / 2];
sum = 0;
- for (i = min_valid; i < min_valid + num_valid; i++)
+ for (i = 0; i < num_valid; i++)
sum = _cairo_time_add (sum, values[i]);
mean = sum / num_valid;
/* Let's use a normalized std. deviation for easier comparison. */
s = 0;
- for (i = min_valid; i < min_valid + num_valid; i++) {
+ for (i = 0; i < num_valid; i++) {
double delta = (values[i] - mean) / (double)mean;
s += delta * delta;
}