diff options
author | Carl Worth <cworth@cworth.org> | 2007-04-19 16:09:06 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2007-04-25 11:27:33 -0700 |
commit | cc03f0499e7b133a2e5c14e55207259ea000b8c2 (patch) | |
tree | f28b6e6fad05faaafa96ea762e03962f2267eddd /perf/cairo-perf-diff-files.c | |
parent | 228c83c9d2d1fdb6fa3af8a650640a47c8e21e36 (diff) | |
download | cairo-cc03f0499e7b133a2e5c14e55207259ea000b8c2.tar.gz |
cairo-perf-diff-files: Sort and compute stats at the time of loading a report
Diffstat (limited to 'perf/cairo-perf-diff-files.c')
-rw-r--r-- | perf/cairo-perf-diff-files.c | 150 |
1 files changed, 75 insertions, 75 deletions
diff --git a/perf/cairo-perf-diff-files.c b/perf/cairo-perf-diff-files.c index e968e6cef..7b64504f2 100644 --- a/perf/cairo-perf-diff-files.c +++ b/perf/cairo-perf-diff-files.c @@ -287,6 +287,78 @@ strndup (const char *s, size_t n) } #endif /* ifndef __USE_GNU */ + +static int +test_report_cmp_backend_then_name (const void *a, const void *b) +{ + const test_report_t *a_test = a; + const test_report_t *b_test = b; + int cmp; + + cmp = strcmp (a_test->backend, b_test->backend); + if (cmp) + return cmp; + + cmp = strcmp (a_test->content, b_test->content); + if (cmp) + return cmp; + + cmp = strcmp (a_test->name, b_test->name); + if (cmp) + return cmp; + + if (a_test->size < b_test->size) + return -1; + if (a_test->size > b_test->size) + return 1; + return 0; +} + +static void +cairo_perf_report_sort_and_compute_stats (cairo_perf_report_t *report) +{ + test_report_t *base, *next, *last, *t; + + /* First we sort, since the diff needs both lists in the same + * order */ + qsort (report->tests, report->tests_count, sizeof (test_report_t), + test_report_cmp_backend_then_name); + + /* The sorting also brings all related raw reports together so we + * can condense them and compute the stats. + */ + base = &report->tests[0]; + last = &report->tests[report->tests_count - 1]; + while (base <= last) { + next = base+1; + if (next <= last) { + while (next <= last && + test_report_cmp_backend_then_name (base, next) == 0) + { + next++; + } + if (next != base) { + unsigned int new_samples_count = base->samples_count; + for (t = base + 1; t < next; t++) + new_samples_count += t->samples_count; + if (new_samples_count > base->samples_size) { + base->samples_size = new_samples_count; + base->samples = xrealloc (base->samples, + base->samples_size * sizeof (cairo_perf_ticks_t)); + } + for (t = base + 1; t < next; t++) { + memcpy (&base->samples[base->samples_count], t->samples, + t->samples_count * sizeof (cairo_perf_ticks_t)); + base->samples_count += t->samples_count; + } + } + } + if (base->samples) + _cairo_stats_compute (&base->stats, base->samples, base->samples_count); + base = next; + } +} + static void cairo_perf_report_load (cairo_perf_report_t *report, const char *filename) { @@ -334,6 +406,8 @@ cairo_perf_report_load (cairo_perf_report_t *report, const char *filename) if (line) free (line); + + cairo_perf_report_sort_and_compute_stats (report); } static int @@ -367,77 +441,6 @@ test_diff_cmp (const void *a, const void *b) return 0; } -static int -test_report_cmp_backend_then_name (const void *a, const void *b) -{ - const test_report_t *a_test = a; - const test_report_t *b_test = b; - int cmp; - - cmp = strcmp (a_test->backend, b_test->backend); - if (cmp) - return cmp; - - cmp = strcmp (a_test->content, b_test->content); - if (cmp) - return cmp; - - cmp = strcmp (a_test->name, b_test->name); - if (cmp) - return cmp; - - if (a_test->size < b_test->size) - return -1; - if (a_test->size > b_test->size) - return 1; - return 0; -} - -static void -cairo_perf_report_sort_and_compute_stats (cairo_perf_report_t *report) -{ - test_report_t *base, *next, *last, *t; - - /* First we sort, since the diff needs both lists in the same - * order */ - qsort (report->tests, report->tests_count, sizeof (test_report_t), - test_report_cmp_backend_then_name); - - /* The sorting also brings all related raw reports together so we - * can condense them and compute the stats. - */ - base = &report->tests[0]; - last = &report->tests[report->tests_count - 1]; - while (base <= last) { - next = base+1; - if (next <= last) { - while (next <= last && - test_report_cmp_backend_then_name (base, next) == 0) - { - next++; - } - if (next != base) { - unsigned int new_samples_count = base->samples_count; - for (t = base + 1; t < next; t++) - new_samples_count += t->samples_count; - if (new_samples_count > base->samples_size) { - base->samples_size = new_samples_count; - base->samples = xrealloc (base->samples, - base->samples_size * sizeof (cairo_perf_ticks_t)); - } - for (t = base + 1; t < next; t++) { - memcpy (&base->samples[base->samples_count], t->samples, - t->samples_count * sizeof (cairo_perf_ticks_t)); - base->samples_count += t->samples_count; - } - } - } - if (base->samples) - _cairo_stats_compute (&base->stats, base->samples, base->samples_count); - base = next; - } -} - #define CHANGE_BAR_WIDTH 70 static void print_change_bar (double change, double max_change, int use_utf) @@ -500,16 +503,13 @@ cairo_perf_report_diff (cairo_perf_report_t *old, diffs = xmalloc (MAX (old->tests_count, new->tests_count) * sizeof (test_diff_t)); - cairo_perf_report_sort_and_compute_stats (old); - cairo_perf_report_sort_and_compute_stats (new); - i_old = 0; i_new = 0; while (i_old < old->tests_count && i_new < new->tests_count) { o = &old->tests[i_old]; n = &new->tests[i_new]; - /* We expect iterations values of 0 when mutltiple raw reports + /* We expect iterations values of 0 when multiple raw reports * for the same test have been condensed into the stats of the * first. So we just skip these later reports that have no * stats. */ |