X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbootchart%2Fsvg.c;h=e111fa9cce57faa612e9957f5b61d675320be160;hb=b267a6d20464a138cae916a676f2c382c51d52de;hp=faf377e506e942f729a2b174c72c709bb9923710;hpb=e931d3f4241231e4102eda06adaf7cbfd68c6a5d;p=elogind.git diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c index faf377e50..e111fa9cc 100644 --- a/src/bootchart/svg.c +++ b/src/bootchart/svg.c @@ -39,6 +39,7 @@ #include "svg.h" #include "bootchart.h" #include "list.h" +#include "utf8.h" #define time_to_graph(t) ((t) * arg_scale_x) #define ps_to_graph(n) ((n) * arg_scale_y) @@ -748,11 +749,14 @@ static void svg_io_bo_bar(void) { } } -static void svg_cpu_bar(void) { +static void svg_cpu_bar(int cpu_num) { svg("\n"); - svg("CPU utilization\n"); + if (cpu_num < 0) + svg("CPU[overall] utilization\n"); + else + svg("CPU[%d] utilization\n", cpu_num); /* surrounding box */ svg_graph_box(5); @@ -765,12 +769,16 @@ static void svg_cpu_bar(void) { ptrt = trt = 0.0; - for (c = 0; c < cpus; c++) - trt += sampledata->runtime[c] - prev_sampledata->runtime[c]; + if (cpu_num < 0) + for (c = 0; c < cpus; c++) + trt += sampledata->runtime[c] - prev_sampledata->runtime[c]; + else + trt = sampledata->runtime[cpu_num] - prev_sampledata->runtime[cpu_num]; trt = trt / 1000000000.0; - trt = trt / (double)cpus; + if (cpu_num < 0) + trt = trt / (double)cpus; if (trt > 0.0) ptrt = trt / (sampledata->sampletime - prev_sampledata->sampletime); @@ -789,11 +797,14 @@ static void svg_cpu_bar(void) { } } -static void svg_wait_bar(void) { +static void svg_wait_bar(int cpu_num) { svg("\n"); - svg("CPU wait\n"); + if (cpu_num < 0) + svg("CPU[overall] wait\n"); + else + svg("CPU[%d] wait\n", cpu_num); /* surrounding box */ svg_graph_box(5); @@ -807,12 +818,16 @@ static void svg_wait_bar(void) { ptwt = twt = 0.0; - for (c = 0; c < cpus; c++) - twt += sampledata->waittime[c] - prev_sampledata->waittime[c]; + if (cpu_num < 0) + for (c = 0; c < cpus; c++) + twt += sampledata->waittime[c] - prev_sampledata->waittime[c]; + else + twt = sampledata->waittime[cpu_num] - prev_sampledata->waittime[cpu_num]; twt = twt / 1000000000.0; - twt = twt / (double)cpus; + if (cpu_num < 0) + twt = twt / (double)cpus; if (twt > 0.0) ptwt = twt / (sampledata->sampletime - prev_sampledata->sampletime); @@ -831,7 +846,6 @@ static void svg_wait_bar(void) { } } - static void svg_entropy_bar(void) { svg("\n"); @@ -1006,12 +1020,15 @@ static void svg_ps_bars(void) { /* pass 2 - ps boxes */ ps = ps_first; while ((ps = get_next_ps(ps))) { - _cleanup_free_ char *enc_name = NULL; + _cleanup_free_ char *enc_name = NULL, *escaped = NULL; double endtime; double starttime; int t; - enc_name = xml_comment_encode(ps->name); + if (!utf8_is_printable(ps->name, strlen(ps->name))) + escaped = utf8_escape_non_printable(ps->name); + + enc_name = xml_comment_encode(escaped ? escaped : ps->name); if (!enc_name) continue; @@ -1100,7 +1117,7 @@ static void svg_ps_bars(void) { svg(" [%i]%.03fs %s\n", time_to_graph(w - graph_start) + 5.0, ps_to_graph(j) + 14.0, - ps->name, + escaped ? escaped : ps->name, ps->pid, (ps->last->runtime - ps->first->runtime) / 1000000000.0, arg_show_cgroup ? ps->cgroup : ""); @@ -1252,6 +1269,8 @@ static void svg_top_ten_pss(void) { void svg_do(const char *build) { struct ps_struct *ps; + double offset = 7; + int c; memzero(&str, sizeof(str)); @@ -1280,25 +1299,31 @@ void svg_do(const char *build) { svg_io_bi_bar(); svg("\n\n"); - svg("\n", 400.0 + (arg_scale_y * 7.0)); + svg("\n", 400.0 + (arg_scale_y * offset)); svg_io_bo_bar(); svg("\n\n"); - svg("\n", 400.0 + (arg_scale_y * 14.0)); - svg_cpu_bar(); - svg("\n\n"); + for (c = -1; c < (arg_percpu ? cpus : 0); c++) { + offset += 7; + svg("\n", 400.0 + (arg_scale_y * offset)); + svg_cpu_bar(c); + svg("\n\n"); - svg("\n", 400.0 + (arg_scale_y * 21.0)); - svg_wait_bar(); - svg("\n\n"); + offset += 7; + svg("\n", 400.0 + (arg_scale_y * offset)); + svg_wait_bar(c); + svg("\n\n"); + } if (kcount) { - svg("\n", 400.0 + (arg_scale_y * 28.0)); + offset += 7; + svg("\n", 400.0 + (arg_scale_y * offset)); svg_do_initcall(0); svg("\n\n"); } - svg("\n", 400.0 + (arg_scale_y * 28.0) + ksize); + offset += 7; + svg("\n", 400.0 + (arg_scale_y * offset) + ksize); svg_ps_bars(); svg("\n\n"); @@ -1311,13 +1336,13 @@ void svg_do(const char *build) { svg("\n\n"); if (arg_entropy) { - svg("\n", 400.0 + (arg_scale_y * 28.0) + ksize + psize); + svg("\n", 400.0 + (arg_scale_y * offset) + ksize + psize); svg_entropy_bar(); svg("\n\n"); } if (arg_pss) { - svg("\n", 400.0 + (arg_scale_y * 28.0) + ksize + psize + esize); + svg("\n", 400.0 + (arg_scale_y * offset) + ksize + psize + esize); svg_pss_graph(); svg("\n\n");