aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2009-09-20 12:14:38 -0400
committerIngo Molnar <mingo@elte.hu>2009-09-20 13:37:36 -0400
commit611a546bec3e1af2a87af0862398fc711dc47aef (patch)
treeee2e222ab0f8a0bee4b6169e6e6a80332edcd10b /tools/perf/util
parent5094b655452dd48367fb28af74ffc76019b93dc2 (diff)
perf util: SVG performance improvements
Tweak the output SVG to increase performance in SVG viewers by limiting the different types of font sizes and by smarter transformations on the text. At least with Inkscape this gives a notable performance improvement during zoom and scrolling. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <20090920181438.3a49cb93@linux.intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/svghelper.c78
1 files changed, 55 insertions, 23 deletions
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index be1555e241b2..a778fd0f4ae4 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -51,6 +51,25 @@ static double time2pixels(u64 time)
51 return X; 51 return X;
52} 52}
53 53
54/*
55 * Round text sizes so that the svg viewer only needs a discrete
56 * number of renderings of the font
57 */
58static double round_text_size(double size)
59{
60 int loop = 100;
61 double target = 10.0;
62
63 if (size >= 10.0)
64 return size;
65 while (loop--) {
66 if (size >= target)
67 return target;
68 target = target / 2.0;
69 }
70 return size;
71}
72
54void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end) 73void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end)
55{ 74{
56 int new_width; 75 int new_width;
@@ -122,8 +141,10 @@ void svg_sample(int Yslot, int cpu, u64 start, u64 end)
122 text_size = text_size/2; 141 text_size = text_size/2;
123 if (text_size > 1.25) 142 if (text_size > 1.25)
124 text_size = 1.25; 143 text_size = 1.25;
144 text_size = round_text_size(text_size);
145
125 if (text_size > MIN_TEXT_SIZE) 146 if (text_size > MIN_TEXT_SIZE)
126 fprintf(svgfile, "<text transform=\"translate(%1.8f,%1.8f)\" font-size=\"%1.6fpt\">%i</text>\n", 147 fprintf(svgfile, "<text x=\"%1.8f\" y=\"%1.8f\" font-size=\"%1.8fpt\">%i</text>\n",
127 time2pixels(start), Yslot * SLOT_MULT + SLOT_HEIGHT - 1, text_size, cpu + 1); 148 time2pixels(start), Yslot * SLOT_MULT + SLOT_HEIGHT - 1, text_size, cpu + 1);
128 149
129} 150}
@@ -162,17 +183,20 @@ void svg_waiting(int Yslot, u64 start, u64 end)
162 183
163 text = time_to_string(end-start); 184 text = time_to_string(end-start);
164 185
165 font_size = 1.0 * (time2pixels(end)-time2pixels(start)) / strlen(text); 186 font_size = 1.0 * (time2pixels(end)-time2pixels(start));
166 187
167 if (font_size > 0.2) 188 if (font_size > 3)
168 font_size = 0.2; 189 font_size = 3;
169 190
191 font_size = round_text_size(font_size);
170 192
171 fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"%s\"/>\n", 193 fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), Yslot * SLOT_MULT);
172 time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT, style); 194 fprintf(svgfile, "<rect x=\"0\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n",
195 time2pixels(end)-time2pixels(start), SLOT_HEIGHT, style);
173 if (font_size > MIN_TEXT_SIZE) 196 if (font_size > MIN_TEXT_SIZE)
174 fprintf(svgfile, "<text transform=\"translate(%1.8f,%1.8f)\" font-size=\"%1.6fpt\">%s</text>\n", 197 fprintf(svgfile, "<text transform=\"rotate(90)\" font-size=\"%1.8fpt\"> %s</text>\n",
175 time2pixels(start), Yslot * SLOT_MULT + 2, font_size, text); 198 font_size, text);
199 fprintf(svgfile, "</g>\n");
176} 200}
177 201
178static char *cpu_model(void) 202static char *cpu_model(void)
@@ -211,7 +235,7 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
211 cpu2y(cpu), SLOT_MULT+SLOT_HEIGHT); 235 cpu2y(cpu), SLOT_MULT+SLOT_HEIGHT);
212 236
213 sprintf(cpu_string, "CPU %i", (int)cpu+1); 237 sprintf(cpu_string, "CPU %i", (int)cpu+1);
214 fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f)\">%s</text>\n", 238 fprintf(svgfile, "<text x=\"%4.8f\" y=\"%4.8f\">%s</text>\n",
215 10+time2pixels(first_time), cpu2y(cpu) + SLOT_HEIGHT/2, cpu_string); 239 10+time2pixels(first_time), cpu2y(cpu) + SLOT_HEIGHT/2, cpu_string);
216 240
217 fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f)\" font-size=\"1.25pt\">%s</text>\n", 241 fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f)\" font-size=\"1.25pt\">%s</text>\n",
@@ -225,15 +249,21 @@ void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name
225 if (!svgfile) 249 if (!svgfile)
226 return; 250 return;
227 251
228 fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"%s\"/>\n", 252
229 time2pixels(start), time2pixels(end)-time2pixels(start), cpu2y(cpu), SLOT_MULT+SLOT_HEIGHT, type); 253 fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu));
254 fprintf(svgfile, "<rect x=\"0\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n",
255 time2pixels(end)-time2pixels(start), SLOT_MULT+SLOT_HEIGHT, type);
230 width = time2pixels(end)-time2pixels(start); 256 width = time2pixels(end)-time2pixels(start);
231 if (width > 6) 257 if (width > 6)
232 width = 6; 258 width = 6;
233 259
260 width = round_text_size(width);
261
234 if (width > MIN_TEXT_SIZE) 262 if (width > MIN_TEXT_SIZE)
235 fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f) rotate(90)\" font-size=\"%3.4fpt\">%s</text>\n", 263 fprintf(svgfile, "<text transform=\"rotate(90)\" font-size=\"%3.8fpt\">%s</text>\n",
236 time2pixels(start), cpu2y(cpu), width, name); 264 width, name);
265
266 fprintf(svgfile, "</g>\n");
237} 267}
238 268
239void svg_cstate(int cpu, u64 start, u64 end, int type) 269void svg_cstate(int cpu, u64 start, u64 end, int type)
@@ -254,13 +284,15 @@ void svg_cstate(int cpu, u64 start, u64 end, int type)
254 time2pixels(start), time2pixels(end)-time2pixels(start), 284 time2pixels(start), time2pixels(end)-time2pixels(start),
255 cpu2y(cpu), SLOT_MULT+SLOT_HEIGHT); 285 cpu2y(cpu), SLOT_MULT+SLOT_HEIGHT);
256 286
257 width = time2pixels(end)-time2pixels(start); 287 width = (time2pixels(end)-time2pixels(start))/2.0;
258 if (width > 6) 288 if (width > 6)
259 width = 6; 289 width = 6;
260 290
291 width = round_text_size(width);
292
261 if (width > MIN_TEXT_SIZE) 293 if (width > MIN_TEXT_SIZE)
262 fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f) rotate(90)\" font-size=\"%3.4fpt\">C%i</text>\n", 294 fprintf(svgfile, "<text x=\"%4.8f\" y=\"%4.8f\" font-size=\"%3.8fpt\">C%i</text>\n",
263 time2pixels(start), cpu2y(cpu), width, type); 295 time2pixels(start), cpu2y(cpu)+width, width, type);
264} 296}
265 297
266static char *HzToHuman(unsigned long hz) 298static char *HzToHuman(unsigned long hz)
@@ -299,7 +331,7 @@ void svg_pstate(int cpu, u64 start, u64 end, u64 freq)
299 height = 1 + cpu2y(cpu) + SLOT_MULT + SLOT_HEIGHT - height; 331 height = 1 + cpu2y(cpu) + SLOT_MULT + SLOT_HEIGHT - height;
300 fprintf(svgfile, "<line x1=\"%4.8f\" x2=\"%4.8f\" y1=\"%4.1f\" y2=\"%4.1f\" class=\"pstate\"/>\n", 332 fprintf(svgfile, "<line x1=\"%4.8f\" x2=\"%4.8f\" y1=\"%4.1f\" y2=\"%4.1f\" class=\"pstate\"/>\n",
301 time2pixels(start), time2pixels(end), height, height); 333 time2pixels(start), time2pixels(end), height, height);
302 fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f)\" font-size=\"0.25pt\">%s</text>\n", 334 fprintf(svgfile, "<text x=\"%4.8f\" y=\"%4.8f\" font-size=\"0.25pt\">%s</text>\n",
303 time2pixels(start), height+0.9, HzToHuman(freq)); 335 time2pixels(start), height+0.9, HzToHuman(freq));
304 336
305} 337}
@@ -318,14 +350,14 @@ void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc
318 fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n", 350 fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n",
319 time2pixels(start), row1 * SLOT_MULT + SLOT_HEIGHT, time2pixels(start), row1 * SLOT_MULT + SLOT_HEIGHT + SLOT_MULT/32); 351 time2pixels(start), row1 * SLOT_MULT + SLOT_HEIGHT, time2pixels(start), row1 * SLOT_MULT + SLOT_HEIGHT + SLOT_MULT/32);
320 if (desc2) 352 if (desc2)
321 fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f) rotate(90)\" font-size=\"0.02pt\">%s &gt;</text>\n", 353 fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\"><text transform=\"rotate(90)\" font-size=\"0.02pt\">%s &gt;</text></g>\n",
322 time2pixels(start), row1 * SLOT_MULT + SLOT_HEIGHT + SLOT_HEIGHT/48, desc2); 354 time2pixels(start), row1 * SLOT_MULT + SLOT_HEIGHT + SLOT_HEIGHT/48, desc2);
323 } 355 }
324 if (row2) { 356 if (row2) {
325 fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n", 357 fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n",
326 time2pixels(start), row2 * SLOT_MULT - SLOT_MULT/32, time2pixels(start), row2 * SLOT_MULT); 358 time2pixels(start), row2 * SLOT_MULT - SLOT_MULT/32, time2pixels(start), row2 * SLOT_MULT);
327 if (desc1) 359 if (desc1)
328 fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f) rotate(90)\" font-size=\"0.02pt\">%s &gt;</text>\n", 360 fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\"><text transform=\"rotate(90)\" font-size=\"0.02pt\">%s &gt;</text></g>\n",
329 time2pixels(start), row2 * SLOT_MULT - SLOT_MULT/32, desc1); 361 time2pixels(start), row2 * SLOT_MULT - SLOT_MULT/32, desc1);
330 } 362 }
331 } else { 363 } else {
@@ -333,14 +365,14 @@ void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc
333 fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n", 365 fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n",
334 time2pixels(start), row2 * SLOT_MULT + SLOT_HEIGHT, time2pixels(start), row2 * SLOT_MULT + SLOT_HEIGHT + SLOT_MULT/32); 366 time2pixels(start), row2 * SLOT_MULT + SLOT_HEIGHT, time2pixels(start), row2 * SLOT_MULT + SLOT_HEIGHT + SLOT_MULT/32);
335 if (desc1) 367 if (desc1)
336 fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f) rotate(90)\" font-size=\"0.02pt\">%s &lt;</text>\n", 368 fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\"><text transform=\"rotate(90)\" font-size=\"0.02pt\">%s &lt;</text></g>\n",
337 time2pixels(start), row2 * SLOT_MULT + SLOT_HEIGHT + SLOT_MULT/48, desc1); 369 time2pixels(start), row2 * SLOT_MULT + SLOT_HEIGHT + SLOT_MULT/48, desc1);
338 } 370 }
339 if (row1) { 371 if (row1) {
340 fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n", 372 fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n",
341 time2pixels(start), row1 * SLOT_MULT - SLOT_MULT/32, time2pixels(start), row1 * SLOT_MULT); 373 time2pixels(start), row1 * SLOT_MULT - SLOT_MULT/32, time2pixels(start), row1 * SLOT_MULT);
342 if (desc2) 374 if (desc2)
343 fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f) rotate(90)\" font-size=\"0.02pt\">%s &lt;</text>\n", 375 fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\"><text transform=\"rotate(90)\" font-size=\"0.02pt\">%s &lt;</text></g>\n",
344 time2pixels(start), row1 * SLOT_MULT - SLOT_HEIGHT/32, desc2); 376 time2pixels(start), row1 * SLOT_MULT - SLOT_HEIGHT/32, desc2);
345 } 377 }
346 } 378 }
@@ -390,7 +422,7 @@ void svg_text(int Yslot, u64 start, const char *text)
390 if (!svgfile) 422 if (!svgfile)
391 return; 423 return;
392 424
393 fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f)\">%s</text>\n", 425 fprintf(svgfile, "<text x=\"%4.8f\" y=\"%4.8f\">%s</text>\n",
394 time2pixels(start), Yslot * SLOT_MULT+SLOT_HEIGHT/2, text); 426 time2pixels(start), Yslot * SLOT_MULT+SLOT_HEIGHT/2, text);
395} 427}
396 428
@@ -401,7 +433,7 @@ static void svg_legenda_box(int X, const char *text, const char *style)
401 433
402 fprintf(svgfile, "<rect x=\"%i\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n", 434 fprintf(svgfile, "<rect x=\"%i\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n",
403 X, boxsize, boxsize, style); 435 X, boxsize, boxsize, style);
404 fprintf(svgfile, "<text transform=\"translate(%4.8f, %4.8f)\" font-size=\"%4.4fpt\">%s</text>\n", 436 fprintf(svgfile, "<text transform=\"translate(%4.8f, %4.8f)\" font-size=\"%4.8fpt\">%s</text>\n",
405 X + boxsize + 5, boxsize, 0.8 * boxsize, text); 437 X + boxsize + 5, boxsize, 0.8 * boxsize, text);
406} 438}
407 439