aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/builtin-report.c11
-rw-r--r--tools/perf/util/values.c62
-rw-r--r--tools/perf/util/values.h3
3 files changed, 73 insertions, 3 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 41639182fb3f..2357c66fb91d 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -57,6 +57,9 @@ static int show_nr_samples;
57static int show_threads; 57static int show_threads;
58static struct perf_read_values show_threads_values; 58static struct perf_read_values show_threads_values;
59 59
60static char default_pretty_printing_style[] = "normal";
61static char *pretty_printing_style = default_pretty_printing_style;
62
60static unsigned long page_size; 63static unsigned long page_size;
61static unsigned long mmap_window = 32; 64static unsigned long mmap_window = 32;
62 65
@@ -1401,6 +1404,9 @@ static size_t output__fprintf(FILE *fp, u64 total_samples)
1401 size_t ret = 0; 1404 size_t ret = 0;
1402 unsigned int width; 1405 unsigned int width;
1403 char *col_width = col_width_list_str; 1406 char *col_width = col_width_list_str;
1407 int raw_printing_style;
1408
1409 raw_printing_style = !strcmp(pretty_printing_style, "raw");
1404 1410
1405 init_rem_hits(); 1411 init_rem_hits();
1406 1412
@@ -1478,7 +1484,8 @@ print_entries:
1478 free(rem_sq_bracket); 1484 free(rem_sq_bracket);
1479 1485
1480 if (show_threads) 1486 if (show_threads)
1481 perf_read_values_display(fp, &show_threads_values); 1487 perf_read_values_display(fp, &show_threads_values,
1488 raw_printing_style);
1482 1489
1483 return ret; 1490 return ret;
1484} 1491}
@@ -2091,6 +2098,8 @@ static const struct option options[] = {
2091 "Show a column with the number of samples"), 2098 "Show a column with the number of samples"),
2092 OPT_BOOLEAN('T', "threads", &show_threads, 2099 OPT_BOOLEAN('T', "threads", &show_threads,
2093 "Show per-thread event counters"), 2100 "Show per-thread event counters"),
2101 OPT_STRING(0, "pretty", &pretty_printing_style, "key",
2102 "pretty printing style key: normal raw"),
2094 OPT_STRING('s', "sort", &sort_order, "key[,key2...]", 2103 OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
2095 "sort by key(s): pid, comm, dso, symbol, parent"), 2104 "sort by key(s): pid, comm, dso, symbol, parent"),
2096 OPT_BOOLEAN('P', "full-paths", &full_paths, 2105 OPT_BOOLEAN('P', "full-paths", &full_paths,
diff --git a/tools/perf/util/values.c b/tools/perf/util/values.c
index 8551c0b8b233..614cfaf4712a 100644
--- a/tools/perf/util/values.c
+++ b/tools/perf/util/values.c
@@ -126,7 +126,8 @@ void perf_read_values_add_value(struct perf_read_values *values,
126 values->value[tindex][cindex] = value; 126 values->value[tindex][cindex] = value;
127} 127}
128 128
129void perf_read_values_display(FILE *fp, struct perf_read_values *values) 129static void perf_read_values__display_pretty(FILE *fp,
130 struct perf_read_values *values)
130{ 131{
131 int i, j; 132 int i, j;
132 int pidwidth, tidwidth; 133 int pidwidth, tidwidth;
@@ -169,3 +170,62 @@ void perf_read_values_display(FILE *fp, struct perf_read_values *values)
169 fprintf(fp, "\n"); 170 fprintf(fp, "\n");
170 } 171 }
171} 172}
173
174static void perf_read_values__display_raw(FILE *fp,
175 struct perf_read_values *values)
176{
177 int width, pidwidth, tidwidth, namewidth, rawwidth, countwidth;
178 int i, j;
179
180 tidwidth = 3; /* TID */
181 pidwidth = 3; /* PID */
182 namewidth = 4; /* "Name" */
183 rawwidth = 3; /* "Raw" */
184 countwidth = 5; /* "Count" */
185
186 for (i = 0; i < values->threads; i++) {
187 width = snprintf(NULL, 0, "%d", values->pid[i]);
188 if (width > pidwidth)
189 pidwidth = width;
190 width = snprintf(NULL, 0, "%d", values->tid[i]);
191 if (width > tidwidth)
192 tidwidth = width;
193 }
194 for (j = 0; j < values->counters; j++) {
195 width = strlen(values->countername[j]);
196 if (width > namewidth)
197 namewidth = width;
198 width = snprintf(NULL, 0, "%llx", values->counterrawid[j]);
199 if (width > rawwidth)
200 rawwidth = width;
201 }
202 for (i = 0; i < values->threads; i++) {
203 for (j = 0; j < values->counters; j++) {
204 width = snprintf(NULL, 0, "%Lu", values->value[i][j]);
205 if (width > countwidth)
206 countwidth = width;
207 }
208 }
209
210 fprintf(fp, "# %*s %*s %*s %*s %*s\n",
211 pidwidth, "PID", tidwidth, "TID",
212 namewidth, "Name", rawwidth, "Raw",
213 countwidth, "Count");
214 for (i = 0; i < values->threads; i++)
215 for (j = 0; j < values->counters; j++)
216 fprintf(fp, " %*d %*d %*s %*llx %*Lu\n",
217 pidwidth, values->pid[i],
218 tidwidth, values->tid[i],
219 namewidth, values->countername[j],
220 rawwidth, values->counterrawid[j],
221 countwidth, values->value[i][j]);
222}
223
224void perf_read_values_display(FILE *fp, struct perf_read_values *values,
225 int raw)
226{
227 if (raw)
228 perf_read_values__display_raw(fp, values);
229 else
230 perf_read_values__display_pretty(fp, values);
231}
diff --git a/tools/perf/util/values.h b/tools/perf/util/values.h
index e41be5e86e6b..f8960fde0547 100644
--- a/tools/perf/util/values.h
+++ b/tools/perf/util/values.h
@@ -21,6 +21,7 @@ void perf_read_values_add_value(struct perf_read_values *values,
21 u32 pid, u32 tid, 21 u32 pid, u32 tid,
22 u64 rawid, char *name, u64 value); 22 u64 rawid, char *name, u64 value);
23 23
24void perf_read_values_display(FILE *fp, struct perf_read_values *values); 24void perf_read_values_display(FILE *fp, struct perf_read_values *values,
25 int raw);
25 26
26#endif /* _PERF_VALUES_H */ 27#endif /* _PERF_VALUES_H */