diff options
| -rw-r--r-- | tools/perf/Documentation/perf-timechart.txt | 3 | ||||
| -rw-r--r-- | tools/perf/builtin-timechart.c | 6 | ||||
| -rw-r--r-- | tools/perf/util/svghelper.c | 30 | ||||
| -rw-r--r-- | tools/perf/util/svghelper.h | 6 |
4 files changed, 31 insertions, 14 deletions
diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt index 61e0104c6270..1c2ed3090cce 100644 --- a/tools/perf/Documentation/perf-timechart.txt +++ b/tools/perf/Documentation/perf-timechart.txt | |||
| @@ -28,6 +28,9 @@ OPTIONS | |||
| 28 | -i:: | 28 | -i:: |
| 29 | --input=:: | 29 | --input=:: |
| 30 | Select the input file (default: perf.data) | 30 | Select the input file (default: perf.data) |
| 31 | -w:: | ||
| 32 | --width=:: | ||
| 33 | Select the width of the SVG file (default: 1000) | ||
| 31 | 34 | ||
| 32 | 35 | ||
| 33 | SEE ALSO | 36 | SEE ALSO |
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 23b3f09d19aa..600406396274 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
| @@ -915,9 +915,9 @@ static void write_svg_file(const char *filename) | |||
| 915 | if (count < 15) | 915 | if (count < 15) |
| 916 | count = determine_display_tasks(TIME_THRESH / 10); | 916 | count = determine_display_tasks(TIME_THRESH / 10); |
| 917 | 917 | ||
| 918 | open_svg(filename, numcpus, count); | 918 | open_svg(filename, numcpus, count, first_time, last_time); |
| 919 | 919 | ||
| 920 | svg_time_grid(first_time, last_time); | 920 | svg_time_grid(); |
| 921 | svg_legenda(); | 921 | svg_legenda(); |
| 922 | 922 | ||
| 923 | for (i = 0; i < numcpus; i++) | 923 | for (i = 0; i < numcpus; i++) |
| @@ -1132,6 +1132,8 @@ static const struct option options[] = { | |||
| 1132 | "input file name"), | 1132 | "input file name"), |
| 1133 | OPT_STRING('o', "output", &output_name, "file", | 1133 | OPT_STRING('o', "output", &output_name, "file", |
| 1134 | "output file name"), | 1134 | "output file name"), |
| 1135 | OPT_INTEGER('w', "width", &svg_page_width, | ||
| 1136 | "page width"), | ||
| 1135 | OPT_END() | 1137 | OPT_END() |
| 1136 | }; | 1138 | }; |
| 1137 | 1139 | ||
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 | |
| 29 | int 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 | ||
| 53 | void open_svg(const char *filename, int cpus, int rows) | 54 | void 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 <