summaryrefslogtreecommitdiff
path: root/perf/cairo-stats.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-07-30 17:28:21 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-09-12 08:29:48 +0100
commitaf9fbd176b145f042408ef5391eef2a51d7531f8 (patch)
tree5f75d1087d4325a013af6f0a4204a666fb4ca4f0 /perf/cairo-stats.c
parent0540bf384aed344899417d3b0313bd6704679c1c (diff)
Introduce a new compositor architecture
Having spent the last dev cycle looking at how we could specialize the compositors for various backends, we once again look for the commonalities in order to reduce the duplication. In part this is motivated by the idea that spans is a good interface for both the existent GL backend and pixman, and so they deserve a dedicated compositor. xcb/xlib target an identical rendering system and so they should be using the same compositor, and it should be possible to run that same compositor locally against pixman to generate reference tests. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> P.S. This brings massive upheaval (read breakage) I've tried delaying in order to fix as many things as possible but now this one patch does far, far, far too much. Apologies in advance for breaking your favourite backend, but trust me in that the end result will be much better. :)
Diffstat (limited to 'perf/cairo-stats.c')
-rw-r--r--perf/cairo-stats.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/perf/cairo-stats.c b/perf/cairo-stats.c
index e088e198..c422d6cc 100644
--- a/perf/cairo-stats.c
+++ b/perf/cairo-stats.c
@@ -25,16 +25,25 @@
#include "cairo-stats.h"
+#include <assert.h>
+
void
_cairo_stats_compute (cairo_stats_t *stats,
cairo_time_t *values,
int num_values)
{
- int i;
- cairo_time_t sumtime;
- double sum, mean, delta, q1, q3, iqr;
- double outlier_min, outlier_max;
- int min_valid, num_valid;
+ cairo_time_t sum, mean, delta, q1, q3, iqr;
+ cairo_time_t outlier_min, outlier_max;
+ int i, min_valid, num_valid;
+
+ assert (num_values > 0);
+
+ if (num_values == 1) {
+ stats->min_ticks = stats->median_ticks = values[0];
+ stats->std_dev = 0;
+ stats->iterations = 1;
+ return;
+ }
/* First, identify any outliers, using the definition of "mild
* outliers" from:
@@ -48,44 +57,35 @@ _cairo_stats_compute (cairo_stats_t *stats,
*/
qsort (values, num_values, sizeof (cairo_time_t), _cairo_time_cmp);
- q1 = _cairo_time_to_s (values[(1*num_values)/4]);
- q3 = _cairo_time_to_s (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;
- outlier_min = _cairo_time_from_s (q1 - 1.5 * iqr);
- outlier_max = _cairo_time_from_s (q3 + 1.5 * iqr);
-
- min_valid = 0;
- while (min_valid < num_values &&
- _cairo_time_to_s (values[min_valid]) < outlier_min)
- {
- min_valid++;
- }
+ for (i = 0; i < num_values && values[i] < outlier_min; i++)
+ ;
+ min_valid = i;
- i = min_valid;
- num_valid = 0;
- while (i + num_valid < num_values &&
- _cairo_time_to_s (values[i+num_valid]) <= outlier_max)
- {
- num_valid++;
- }
+ for (i = 0; i < num_values && values[i] <= outlier_max; i++)
+ ;
+ num_valid = i - min_valid;
+ assert(num_valid);
stats->iterations = num_valid;
stats->min_ticks = values[min_valid];
-
- sumtime = _cairo_time_from_s (0);
- for (i = min_valid; i < min_valid + num_valid; i++) {
- sumtime = _cairo_time_add (sumtime, values[i]);
- stats->min_ticks = _cairo_time_min (stats->min_ticks, values[i]);
- }
-
- mean = _cairo_time_to_s (sumtime) / num_valid;
stats->median_ticks = values[min_valid + num_valid / 2];
- sum = 0.0;
+ sum = 0;
+ for (i = min_valid; i < min_valid + num_valid; i++)
+ sum = _cairo_time_add (sum, values[i]);
+ mean = sum / num_valid;
+
+ sum = 0;
for (i = min_valid; i < min_valid + num_valid; i++) {
- delta = _cairo_time_to_s (values[i]) - mean;
+ delta = values[i] - mean;
sum += delta * delta;
}