aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/values.c
diff options
context:
space:
mode:
authorBrice Goglin <Brice.Goglin@inria.fr>2009-08-10 09:26:32 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-10 09:48:17 -0400
commit9f8666971185b86615a074bcac67c90fdf8af8bc (patch)
tree65ce554d9f7eea0c4458a1051ea1c1469a51a47f /tools/perf/util/values.c
parent8d51327090ac025d7f4ce6c059786b5e93513321 (diff)
perf report: Add raw displaying of per-thread counters
If --pretty=raw is given to perf report -T, it now displays one line per-thread per-counter with the raw event id added. We get: # PID TID Name Raw Count 18608 18609 cache-misses 28e 416744 18608 18609 cache-references 28f 6456792 18608 18608 cache-misses 28e 448219 18608 18608 cache-references 28f 7270244 instead of: # PID TID cache-misses cache-references 18608 18609 416744 6456792 18608 18608 448219 7270244 Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr> Acked-by: Peter Zijlstra <peterz@infradead.org> LKML-Reference: <4A802008.5050409@inria.fr> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/values.c')
-rw-r--r--tools/perf/util/values.c62
1 files changed, 61 insertions, 1 deletions
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}