diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-04-01 05:01:28 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-04-01 05:01:28 -0400 |
commit | c3aefad81f4c9cca36c99408b14d517dc0b4e503 (patch) | |
tree | c0f27b5dee48274f218eb30e1317574b57608f48 | |
parent | 614578605feb96af31a6eeb4aaa4584eff7857da (diff) |
Tweaks to bar graphsrelease
-rw-r--r-- | printbar.c | 135 |
1 files changed, 91 insertions, 44 deletions
@@ -31,18 +31,19 @@ #include <stdio.h> #include <math.h> #include <stdlib.h> +#include <string.h> #define TRUE 1 #define FALSE 0 -#define CHANGE_BAR_WIDTH 70 +#define CHANGE_BAR_WIDTH 40 #define USE_UTF TRUE static void print_change_bar (const char *header, int header_len, double change, double max_change, int use_utf) { - int units_per_cell = ceil (max_change / CHANGE_BAR_WIDTH); + double units_per_cell = max_change / CHANGE_BAR_WIDTH; static char const *ascii_boxes[8] = { "****","***", "***", "**", "**", "*", "*", "" @@ -52,18 +53,26 @@ print_change_bar (const char *header, int header_len, "▌", "▍", "▎", "▏" }; char const **boxes = use_utf ? utf_boxes : ascii_boxes; + double orig_change = change; char format[64]; + int neg; snprintf (format, sizeof format, "%%%ds", header_len); printf (format, header); - /* For a 1.0x speedup we want a zero-size bar to show "no - * change". */ - change -= 1.0; - + if (change < 0) + { + neg = 1; + change = - change; + } + else + { + neg = 0; + } + while (change > units_per_cell) { - printf ("%s", boxes[0]); + printf ("%s", neg? "▒" : boxes[0]); change -= units_per_cell; } @@ -86,6 +95,8 @@ print_change_bar (const char *header, int header_len, else if (change > 0.5/8.0) printf ("%s", boxes[7]); + printf (" %.2fx", 1 / (1 - orig_change)); + printf ("\n"); } @@ -100,9 +111,10 @@ typedef struct target_t target; double before; double after; + double change; } benchmark_t; -static const benchmark_t x86[] = +static benchmark_t x86[] = { { "evolution", IMAGE, 18.365, 17.314 }, { "evolution", IMAGE16, 9.474, 8.371 }, @@ -120,7 +132,7 @@ static const benchmark_t x86[] = { "firefox-talos-svg", IMAGE16, 72.445, 69.429 }, { "firefox-talos-svg", XLIB, 82.937, 78.077 }, - { "gnome-system-monito", IMAGE, 14.760, 7.393 }, + { "gnome-system-monitor", IMAGE, 14.760, 7.393 }, { "gnome-system-monitor", IMAGE16, 14.794, 7.413 }, { "gnome-system-monitor", XLIB, 13.012, 12.889 }, @@ -136,24 +148,24 @@ static const benchmark_t x86[] = { "gvim", IMAGE16, 9.664, 9.778 }, { "gvim", XLIB, 20.503, 19.747 }, - { "swfdec-giant-steps", IMAGE16, 4.681, 4.197 }, { "swfdec-giant-steps", IMAGE, 2.614, 2.495 }, + { "swfdec-giant-steps", IMAGE16, 4.681, 4.197 }, { "swfdec-giant-steps", XLIB, 3.660, 3.672 }, - { "swfdec-youtub", IMAGE, 6.803, 4.596 }, + { "swfdec-youtube", IMAGE, 6.803, 4.596 }, { "swfdec-youtube", IMAGE16, 8.991, 8.008 }, { "swfdec-youtube", XLIB, 7.182, 4.950 }, { NULL }, }; -static const benchmark_t arm[] = +static benchmark_t arm[] = { { "evolution", IMAGE, 181.479, 175.006 }, { "evolution", IMAGE16, 95.043, 91.641 }, { "evolution", XLIB, 189.649, 199.227 }, - { "firefox-planet-gnomd", IMAGE, 297.169, 233.254 }, + { "firefox-planet-gnome", IMAGE, 297.169, 233.254 }, { "firefox-planet-gnome", IMAGE16, 248.348, 239.688 }, { "firefox-planet-gnome", XLIB, 393.300, 301.768 }, @@ -165,7 +177,7 @@ static const benchmark_t arm[] = { "firefox-talos-svg", IMAGE16, 712.566, 616.099 }, { "firefox-talos-svg", XLIB, 872.636, 764.265 }, - { "gnome-system-monito", IMAGE, 115.268, 65.759 }, + { "gnome-system-monitor", IMAGE, 115.268, 65.759 }, { "gnome-system-monitor", IMAGE16, 113.866, 65.893 }, { "gnome-system-monitor", XLIB, 123.724, 114.435 }, @@ -192,48 +204,83 @@ static const benchmark_t arm[] = }; static void -print_benchmarks (const benchmark_t benchmarks[]) +print_benchmarks (benchmark_t benchmarks[], double max) { int i; - double max = 0.0; + char *last_name = NULL; - i = 0; + printf ("\n\n"); + printf (" %s\n", benchmarks == x86 ? "x86" : "ARM"); + i = 0; while (benchmarks[i].name) { - if (benchmarks[i].before > max) - max = benchmarks[i].before; - - if (benchmarks[i].after > max) - max = benchmarks[i].after; - - i++; + char *target; + char label [256]; + int d = 0; + + switch (benchmarks[i].target) + { + case IMAGE: target = "image "; break; + case IMAGE16: target = "image16 "; break; + case XLIB: target = "xlib "; break; + } + + if (!last_name || strcmp (benchmarks[i].name, last_name) != 0) + { + int j; + last_name = benchmarks[i].name; + + printf (" %s ", benchmarks[i].name); + for (j = strlen (benchmarks[i].name) + 2; j < 25; ++j) + printf ("."); + + printf (" "); + d = 32; + } + else + { + snprintf (label, sizeof label, "%32s", target); + } + + print_change_bar (target, 32 - d, benchmarks[i].change, max, USE_UTF); + + ++i; } +} - i = 0; +int +main () +{ + double max; - char *last_name = NULL; + benchmark_t *bm[2] = {x86, arm}; + int j; - printf ("%16s- - %s - - \n", " ", benchmarks == x86 ? "x86" : "ARM"); - - while (benchmarks[i].name) - { - double before = benchmarks[i].before; - double after = benchmarks[i].after; + max = 0.0; - if (last_name && strcmp (last_name, benchmarks[i].name) != 0) - printf ("%s\n", benchmarks[i].name); + for (j = 0; j < 2; ++j) + { + int i = 0; + benchmark_t *benchmarks = bm[j]; - print_change_bar ("0.16.6 ", 16, before, max, USE_UTF); - print_change_bar ("0.18.0 ", 16, after, max, USE_UTF); - - i++; + while (benchmarks[i].name) + { + double before = benchmarks[i].before; + double after = benchmarks[i].after; + double change = (before - after) / before; + + benchmarks[i].change = change; + + if (fabs (change) > max) + max = fabs (change); + + i++; + } } -} -int -main () -{ - print_benchmarks (x86); - print_benchmarks (arm); + print_benchmarks (x86, max); + print_benchmarks (arm, max); + + return 0; } |