aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoan-Sin Tan <freedom.tan@linaro.org>2014-11-27 17:10:49 +0800
committerTuukka Tikkanen <tuukka.tikkanen@linaro.org>2014-11-28 06:35:13 +0200
commit73b0121e97a604ee0d97c66c41b239dc76739ae7 (patch)
treeaa12d8162caea42c98a61d607bb5eaef73f51bad
parent62924570fcb8a84040ecfd02b280366fdb2cf7e8 (diff)
Add boxless report format
The boxless format is more Braille terminal friendly. It's default one without | and - for box boundaries. Trailing spaces have been removed where such would appear after removal of right edge of the box. This report format can be invoked with the -B option. Implementation shares some functions with default report format and is added to default_report.c. Signed-off-by: Koan-Sin Tan <freedom.tan@linaro.org> Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
-rw-r--r--Makefile3
-rw-r--r--default_report.c193
-rw-r--r--idlestat.c10
-rw-r--r--report_ops.h1
4 files changed, 170 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index 4abf57a..e83130e 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,8 @@
CFLAGS?=-g -Wall
CC=gcc
-OBJS = idlestat.o topology.o trace.o utils.o energy_model.o default_report.o csv_report.o
+OBJS = idlestat.o topology.o trace.o utils.o energy_model.o \
+ default_report.o csv_report.o
default: idlestat
diff --git a/default_report.c b/default_report.c
index d900dae..95f72f9 100644
--- a/default_report.c
+++ b/default_report.c
@@ -35,21 +35,20 @@ static int default_close_report_file(void *report_data)
return (fclose(stdout) == EOF) ? -1 : 0;
}
-static void default_cstate_table_header(void *report_data)
-{
- charrep('-', 80);
- printf("\n");
- printf("| C-state | min | max | avg | total | hits | over | under |\n");
-}
+/* Topology headers for all tables (C-state/P-state/Wakeups) */
-static void default_cstate_table_footer(void *report_data)
+static void boxless_cpu_header(const char *cpu, void *report_data)
{
- charrep('-', 80);
- printf("\n\n");
+ /* No pipe characters and less aggressive indentions */
+ if (strstr(cpu, "cluster"))
+ printf(" %s\n", cpu);
+ else if (strstr(cpu, "core"))
+ printf(" %s\n", cpu);
+ else printf(" %s\n", cpu);
}
-static void default_cpu_header(const char *cpu, void *report_data, int len)
+static void default_cpu_header(const char *cpu, int len)
{
charrep('-', len);
printf("\n");
@@ -64,9 +63,49 @@ static void default_cpu_header(const char *cpu, void *report_data, int len)
printf("\n");
}
+static void default_end_cpu(void *report_data)
+{
+}
+
+static void boxless_end_cpu(void *report_data)
+{
+ printf("\n");
+}
+
+
+/* C-states */
+
+static void boxless_cstate_table_header(void *report_data)
+{
+ /* Note: Data is right-aligned, so boxless headers are too */
+ printf(" C-state min max avg total hits over under\n");
+}
+
+static void default_cstate_table_header(void *report_data)
+{
+ /* Note: Boxed header columns appear centered */
+ charrep('-', 80);
+ printf("\n| C-state | min | max | avg | total | hits | over | under |\n");
+}
+
static void default_cstate_cpu_header(const char *cpu, void *report_data)
{
- default_cpu_header(cpu, report_data, 80);
+ default_cpu_header(cpu, 80);
+}
+
+static void boxless_cstate_single_state(struct cpuidle_cstate *c, void *report_data)
+{
+ printf(" %8s ", c->name);
+ display_factored_time(c->min_time == DBL_MAX ? 0. :
+ c->min_time, 8);
+ printf(" ");
+ display_factored_time(c->max_time, 8);
+ printf(" ");
+ display_factored_time(c->avg_time, 8);
+ printf(" ");
+ display_factored_time(c->duration, 8);
+ printf(" ");
+ printf("%5d %5d %5d\n", c->nrdata, c->early_wakings, c->late_wakings);
}
static void default_cstate_single_state(struct cpuidle_cstate *c, void *report_data)
@@ -81,13 +120,27 @@ static void default_cstate_single_state(struct cpuidle_cstate *c, void *report_d
printf(" | ");
display_factored_time(c->duration, 8);
printf(" | ");
- printf("%5d | %5d | %5d |", c->nrdata, c->early_wakings, c->late_wakings);
+ printf("%5d | %5d | %5d |\n", c->nrdata, c->early_wakings, c->late_wakings);
+}
+static void boxless_cstate_table_footer(void *report_data)
+{
printf("\n");
}
-static void default_cstate_end_cpu(void *report_data)
+static void default_cstate_table_footer(void *report_data)
{
+ charrep('-', 80);
+ printf("\n\n");
+}
+
+
+/* P-states */
+
+static void boxless_pstate_table_header(void *report_data)
+{
+ /* Note: Data is right-aligned, so boxless headers are too */
+ printf(" P-state min max avg total hits\n");
}
static void default_pstate_table_header(void *report_data)
@@ -95,23 +148,32 @@ static void default_pstate_table_header(void *report_data)
charrep('-', 64);
printf("\n");
+ /* Note: Boxed header columns appear centered */
printf("| P-state | min | max | avg | total | hits |\n");
}
-static void default_pstate_table_footer(void *report_data)
+static void default_pstate_cpu_header(const char *cpu, void *report_data)
{
- charrep('-', 64);
- printf("\n\n");
+ default_cpu_header(cpu, 64);
}
-static void default_pstate_cpu_header(const char *cpu, void *report_data)
+static void boxless_pstate_single_state(struct cpufreq_pstate *p, void *report_data)
{
- default_cpu_header(cpu, report_data, 64);
+ printf(" ");
+ display_factored_freq(p->freq, 8);
+ printf(" ");
+ display_factored_time(p->min_time == DBL_MAX ? 0. : p->min_time, 8);
+ printf(" ");
+ display_factored_time(p->max_time, 8);
+ printf(" ");
+ display_factored_time(p->avg_time, 8);
+ printf(" ");
+ display_factored_time(p->duration, 8);
+ printf(" %5d\n", p->count);
}
static void default_pstate_single_state(struct cpufreq_pstate *p, void *report_data)
{
-
printf("| ");
display_factored_freq(p->freq, 8);
printf(" | ");
@@ -122,29 +184,57 @@ static void default_pstate_single_state(struct cpufreq_pstate *p, void *report_d
display_factored_time(p->avg_time, 8);
printf(" | ");
display_factored_time(p->duration, 8);
- printf(" | ");
- printf("%5d", p->count);
- printf(" | ");
+ printf(" | %5d |\n", p->count);
+}
+
+static void boxless_pstate_table_footer(void *report_data)
+{
printf("\n");
}
+static void default_pstate_table_footer(void *report_data)
+{
+ charrep('-', 64);
+ printf("\n\n");
+}
+
+
+/* Wakeups */
+
+static void boxless_wakeup_table_header(void *report_data)
+{
+ /*
+ * Note: Columns 1 and 2 are left-aligned, others are right-aligned.
+ * Boxless headers follow the data convention
+ */
+ printf(" IRQ Name Count early late\n");
+}
+
static void default_wakeup_table_header(void *report_data)
{
charrep('-', 55);
printf("\n");
+ /* Note: Boxed header columns appear centered */
printf("| IRQ | Name | Count | early | late |\n");
}
-static void default_wakeup_table_footer(void *report_data)
+static void default_wakeup_cpu_header(const char *cpu, void *report_data)
{
- charrep('-', 55);
- printf("\n\n");
+ default_cpu_header(cpu, 55);
}
-static void default_wakeup_cpu_header(const char *cpu, void *report_data)
+static void boxless_wakeup_single_state(struct wakeup_irq *irqinfo, void *report_data)
{
- default_cpu_header(cpu, report_data, 55);
+ if (irqinfo->id != -1) {
+ printf(" %-3d %-15.15s %7d %7d %7d\n",
+ irqinfo->id, irqinfo->name, irqinfo->count,
+ irqinfo->early_triggers, irqinfo->late_triggers);
+ } else {
+ printf(" IPI %-15.15s %7d %7d %7d\n",
+ irqinfo->name, irqinfo->count,
+ irqinfo->early_triggers, irqinfo->late_triggers);
+ }
}
static void default_wakeup_single_state(struct wakeup_irq *irqinfo, void *report_data)
@@ -160,27 +250,64 @@ static void default_wakeup_single_state(struct wakeup_irq *irqinfo, void *report
}
}
+static void boxless_wakeup_table_footer(void *report_data)
+{
+ printf("\n");
+}
+
+static void default_wakeup_table_footer(void *report_data)
+{
+ charrep('-', 55);
+ printf("\n\n");
+}
+
+
struct report_ops default_report_ops = {
- .check_output = default_check_output,
+ .check_output = default_check_output, /* Shared */
- .open_report_file = default_open_report_file,
- .close_report_file = default_close_report_file,
+ .open_report_file = default_open_report_file, /* Shared */
+ .close_report_file = default_close_report_file, /* Shared */
.cstate_table_header = default_cstate_table_header,
.cstate_table_footer = default_cstate_table_footer,
.cstate_cpu_header = default_cstate_cpu_header,
.cstate_single_state = default_cstate_single_state,
- .cstate_end_cpu = default_cstate_end_cpu,
+ .cstate_end_cpu = default_end_cpu,
.pstate_table_header = default_pstate_table_header,
.pstate_table_footer = default_pstate_table_footer,
.pstate_cpu_header = default_pstate_cpu_header,
.pstate_single_state = default_pstate_single_state,
- .pstate_end_cpu = default_cstate_end_cpu,
+ .pstate_end_cpu = default_end_cpu,
.wakeup_table_header = default_wakeup_table_header,
.wakeup_table_footer = default_wakeup_table_footer,
.wakeup_cpu_header = default_wakeup_cpu_header,
.wakeup_single_state = default_wakeup_single_state,
- .wakeup_end_cpu = default_cstate_end_cpu,
+ .wakeup_end_cpu = default_end_cpu,
+};
+
+struct report_ops boxless_report_ops = {
+ .check_output = default_check_output,
+
+ .open_report_file = default_open_report_file,
+ .close_report_file = default_close_report_file,
+
+ .cstate_table_header = boxless_cstate_table_header,
+ .cstate_table_footer = boxless_cstate_table_footer,
+ .cstate_cpu_header = boxless_cpu_header,
+ .cstate_single_state = boxless_cstate_single_state,
+ .cstate_end_cpu = boxless_end_cpu,
+
+ .pstate_table_header = boxless_pstate_table_header,
+ .pstate_table_footer = boxless_pstate_table_footer,
+ .pstate_cpu_header = boxless_cpu_header,
+ .pstate_single_state = boxless_pstate_single_state,
+ .pstate_end_cpu = boxless_end_cpu,
+
+ .wakeup_table_header = boxless_wakeup_table_header,
+ .wakeup_table_footer = boxless_wakeup_table_footer,
+ .wakeup_cpu_header = boxless_cpu_header,
+ .wakeup_single_state = boxless_wakeup_single_state,
+ .wakeup_end_cpu = boxless_end_cpu,
};
diff --git a/idlestat.c b/idlestat.c
index 98de74d..47f975e 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -1211,11 +1211,11 @@ static void help(const char *cmd)
fprintf(stderr,
"\nUsage:\nTrace mode:\n\t%s --trace -f|--trace-file <filename>"
" -o|--output-file <filename> -t|--duration <seconds>"
- " -C|--csv-report"
+ " -C|--csv-report -B|--boxless-report"
" -c|--idle -p|--frequency -w|--wakeup", basename(cmd));
fprintf(stderr,
"\nReporting mode:\n\t%s --import -f|--trace-file <filename>"
- " -C|--csv-report"
+ " -C|--csv-report -B|--boxless-report"
" -o|--output-file <filename>", basename(cmd));
fprintf(stderr,
"\n\nExamples:\n1. Run a trace, post-process the results"
@@ -1259,6 +1259,7 @@ int getoptions(int argc, char *argv[], struct program_options *options)
{ "wakeup", no_argument, NULL, 'w' },
{ "energy-model-file", required_argument, NULL, 'e' },
{ "csv-report", no_argument, NULL, 'C' },
+ { "boxless-report", no_argument, NULL, 'B' },
{ 0, 0, 0, 0 }
};
int c;
@@ -1274,7 +1275,7 @@ int getoptions(int argc, char *argv[], struct program_options *options)
int optindex = 0;
- c = getopt_long(argc, argv, ":de:f:o:ht:cpwVvC",
+ c = getopt_long(argc, argv, ":de:f:o:ht:cpwVvCB",
long_options, &optindex);
if (c == -1)
break;
@@ -1315,6 +1316,9 @@ int getoptions(int argc, char *argv[], struct program_options *options)
case 'C':
options->report_ops = &csv_report_ops;
break;
+ case 'B':
+ options->report_ops = &boxless_report_ops;
+ break;
case 0: /* getopt_long() set a variable, just keep going */
break;
case ':': /* missing option argument */
diff --git a/report_ops.h b/report_ops.h
index ad77b2e..e502902 100644
--- a/report_ops.h
+++ b/report_ops.h
@@ -3,5 +3,6 @@
extern struct report_ops default_report_ops;
extern struct report_ops csv_report_ops;
+extern struct report_ops boxless_report_ops;
#endif