summaryrefslogtreecommitdiff
path: root/perf/cairo-stats.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-06-11 11:05:03 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-06-11 11:30:43 +0100
commit9a12c2e02369f0920c1f1f578eb8d228add77ea1 (patch)
treea8c0e8772c894d06f8030813ea9c7bd85577c5fd /perf/cairo-stats.c
parente519d6f9860c7f0bc51f1e8a17505f2dc372c938 (diff)
downloadcairo-9a12c2e02369f0920c1f1f578eb8d228add77ea1.tar.gz
perf: Rudimentary histogram printing for cairo-perf-print
If you call ./cairo-perf-print --histogram results.txt, it will then print a histogram of the results, one per test. Ideally, you should see a skewed distribution (with a negative skew representing that most results run in optimal time), but random sampling errors (scheduling, throttling, general inefficiency etc) will push it more towards a normal distribution. For example, | x | | x xx | | x xx | | x xx | | xxxx | | xxxx x | | x xxxxxx | | x xxxxxx | | xxxxxxxxx | | xxxxxxxxx | | xxxxxxxxx | | xxxxxxxxxxxx | | xxxxxxxxxxxx | | xxxxxxxxxxxx | | xxxxxxxxxxxxxx | |x xxxxxxxxxxxxxx | |x x xxxxxxxxxxxxxxx | |x x xxxxxxxxxxxxxxx | |x x xxxxxxxxxxxxxxxxx | |xxx x xxxxxxxxxxxxxxxxxxx | |xxx xxxxxxxxxxxxxxxxxxxxxxxxx | |xxxxxx xxxx x x x x xxx xx xxxxx xxx x xxx x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| .------------------------------------------------------------------------------. xlib firefox-fishtank 8298.44 1.53% (829/946) Starts off reasonably, but quickly deteriorates as the integrated CPU/GPU overheats and is forced to throttle. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'perf/cairo-stats.c')
-rw-r--r--perf/cairo-stats.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/perf/cairo-stats.c b/perf/cairo-stats.c
index 7a36a138f..c10c92192 100644
--- a/perf/cairo-stats.c
+++ b/perf/cairo-stats.c
@@ -43,6 +43,7 @@ _cairo_stats_compute (cairo_stats_t *stats,
stats->min_ticks = stats->median_ticks = values[0];
stats->std_dev = 0;
stats->iterations = 1;
+ stats->values = values;
return;
}
@@ -80,6 +81,7 @@ _cairo_stats_compute (cairo_stats_t *stats,
values += min_valid;
} while (num_valid != num_values);
+ stats->values = values;
stats->iterations = num_valid;
stats->min_ticks = values[0];
stats->median_ticks = values[num_valid / 2];
@@ -97,3 +99,81 @@ _cairo_stats_compute (cairo_stats_t *stats,
}
stats->std_dev = sqrt(s / num_valid);
}
+
+cairo_bool_t
+_cairo_histogram_init (cairo_histogram_t *h,
+ int width, int height)
+{
+ h->width = width;
+ h->height = height;
+ if (h->width < 2 || h->height < 1)
+ return FALSE;
+
+ h->num_columns = width - 2;
+ h->num_rows = height - 1;
+ h->columns = malloc (sizeof(int)*h->num_columns);
+ return h->columns != NULL;
+}
+
+cairo_bool_t
+_cairo_histogram_compute (cairo_histogram_t *h,
+ const cairo_time_t *values,
+ int num_values)
+{
+ cairo_time_t delta;
+ int i;
+
+ if (num_values == 0)
+ return FALSE;
+
+ h->min_value = values[0];
+ h->max_value = values[0];
+
+ for (i = 1; i < num_values; i++) {
+ if (values[i] < h->min_value)
+ h->min_value = values[i];
+ if (values[i] > h->max_value)
+ h->max_value = values[i];
+ }
+
+ delta = h->max_value - h->min_value;
+ if (delta == 0)
+ return FALSE;
+
+ memset(h->columns, 0, sizeof(int)*h->num_columns);
+ h->max_count = 0;
+
+ for (i = 0; i < num_values; i++) {
+ int count = h->columns[(values[i] - h->min_value) * (h->num_columns - 1) / delta]++;
+ if (count > h->max_count)
+ h->max_count = count;
+ }
+
+ return TRUE;
+}
+
+void
+_cairo_histogram_printf (cairo_histogram_t *h,
+ FILE *file)
+{
+ int x, y;
+
+ for (y = 0; y < h->num_rows; y++) {
+ int min_count = (h->num_rows - y - 1) * h->max_count / h->num_rows;
+ fprintf (file, "|");
+ for (x = 0; x < h->num_columns; x++)
+ fprintf (file, "%c", h->columns[x] > min_count ? 'x' : ' ');
+ fprintf (file, "|\n");
+ }
+
+ fprintf(file, ".");
+ for (x = 0; x < h->num_columns; x++)
+ fprintf (file, "-");
+ fprintf (file, ".\n");
+}
+
+void
+_cairo_histogram_fini (cairo_histogram_t *h)
+{
+ free(h->columns);
+}