aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2009-09-20 12:14:16 -0400
committerIngo Molnar <mingo@elte.hu>2009-09-20 13:37:35 -0400
commit5094b655452dd48367fb28af74ffc76019b93dc2 (patch)
tree72412b375275b943fc417c7e3c55bf50833e9683 /tools/perf/util
parenta92fe7b3063db2caa578872fce975ff53aa56214 (diff)
perf util: Make the timechart SVG width dynamic
This patch adds a command line option for timechart that allows the user to specify the width of the SVG file. This patch also makes sure that each second of recording has at least 200 units (pixels at 96 DPI) of width. This impacts recordings longer than 5 seconds; recordings shorter than 5 second will scale up to have a width of 1000 units for the whole recording (as before). 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: <20090920181416.69570c5d@linux.intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/svghelper.c30
-rw-r--r--tools/perf/util/svghelper.h6
2 files changed, 24 insertions, 12 deletions
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index 52f628fe6421..be1555e241b2 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -25,7 +25,8 @@ static u64 turbo_frequency, max_freq;
25 25
26#define SLOT_MULT 30.0 26#define SLOT_MULT 30.0
27#define SLOT_HEIGHT 25.0 27#define SLOT_HEIGHT 25.0
28#define WIDTH 1000.0 28
29int svg_page_width = 1000;
29 30
30#define MIN_TEXT_SIZE 0.001 31#define MIN_TEXT_SIZE 0.001
31 32
@@ -46,21 +47,35 @@ static double time2pixels(u64 time)
46{ 47{
47 double X; 48 double X;
48 49
49 X = WIDTH * (time - first_time) / (last_time - first_time); 50 X = 1.0 * svg_page_width * (time - first_time) / (last_time - first_time);
50 return X; 51 return X;
51} 52}
52 53
53void open_svg(const char *filename, int cpus, int rows) 54void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end)
54{ 55{
56 int new_width;
55 57
56 svgfile = fopen(filename, "w"); 58 svgfile = fopen(filename, "w");
57 if (!svgfile) { 59 if (!svgfile) {
58 fprintf(stderr, "Cannot open %s for output\n", filename); 60 fprintf(stderr, "Cannot open %s for output\n", filename);
59 return; 61 return;
60 } 62 }
63 first_time = start;
64 first_time = first_time / 100000000 * 100000000;
65 last_time = end;
66
67 /*
68 * if the recording is short, we default to a width of 1000, but
69 * for longer recordings we want at least 200 units of width per second
70 */
71 new_width = (last_time - first_time) / 5000000;
72
73 if (new_width > svg_page_width)
74 svg_page_width = new_width;
75
61 total_height = (1 + rows + cpu2slot(cpus)) * SLOT_MULT; 76 total_height = (1 + rows + cpu2slot(cpus)) * SLOT_MULT;
62 fprintf(svgfile, "<?xml version=\"1.0\" standalone=\"no\"?> \n"); 77 fprintf(svgfile, "<?xml version=\"1.0\" standalone=\"no\"?> \n");
63 fprintf(svgfile, "<svg width=\"%4.1f\" height=\"%llu\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n", WIDTH, total_height); 78 fprintf(svgfile, "<svg width=\"%i\" height=\"%llu\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n", svg_page_width, total_height);
64 79
65 fprintf(svgfile, "<defs>\n <style type=\"text/css\">\n <![CDATA[\n"); 80 fprintf(svgfile, "<defs>\n <style type=\"text/css\">\n <![CDATA[\n");
66 81
@@ -404,15 +419,10 @@ void svg_legenda(void)
404 svg_legenda_box(800, "Blocked on IO", "blocked"); 419 svg_legenda_box(800, "Blocked on IO", "blocked");
405} 420}
406 421
407void svg_time_grid(u64 start, u64 end) 422void svg_time_grid(void)
408{ 423{
409 u64 i; 424 u64 i;
410 425
411 first_time = start;
412 last_time = end;
413
414 first_time = first_time / 100000000 * 100000000;
415
416 if (!svgfile) 426 if (!svgfile)
417 return; 427 return;
418 428
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index ed4ebcfaf493..cd93195aedb3 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -3,7 +3,7 @@
3 3
4#include "types.h" 4#include "types.h"
5 5
6extern void open_svg(const char *filename, int cpus, int rows); 6extern void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end);
7extern void svg_box(int Yslot, u64 start, u64 end, const char *type); 7extern void svg_box(int Yslot, u64 start, u64 end, const char *type);
8extern void svg_sample(int Yslot, int cpu, u64 start, u64 end); 8extern void svg_sample(int Yslot, int cpu, u64 start, u64 end);
9extern void svg_waiting(int Yslot, u64 start, u64 end); 9extern void svg_waiting(int Yslot, u64 start, u64 end);
@@ -15,7 +15,7 @@ extern void svg_cstate(int cpu, u64 start, u64 end, int type);
15extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq); 15extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
16 16
17 17
18extern void svg_time_grid(u64 start, u64 end); 18extern void svg_time_grid(void);
19extern void svg_legenda(void); 19extern void svg_legenda(void);
20extern void svg_wakeline(u64 start, int row1, int row2); 20extern void svg_wakeline(u64 start, int row1, int row2);
21extern void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc2); 21extern void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc2);
@@ -23,4 +23,6 @@ extern void svg_interrupt(u64 start, int row);
23extern void svg_text(int Yslot, u64 start, const char *text); 23extern void svg_text(int Yslot, u64 start, const char *text);
24extern void svg_close(void); 24extern void svg_close(void);
25 25
26extern int svg_page_width;
27
26#endif 28#endif