X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbootchart%2Fsvg.c;h=bf6636cab1d8c26b0c2f9d12a2baac7869faf863;hp=231d3daa8002a1526873f4f9d968dad4b8dca7e6;hb=e70bc43cdf75b36e7ad3d29e9a6f8ee1461e7d5e;hpb=6d031c0b6037ac7308d31562c09fb8ac714e82b4 diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c index 231d3daa8..bf6636cab 100644 --- a/src/bootchart/svg.c +++ b/src/bootchart/svg.c @@ -3,7 +3,7 @@ /*** This file is part of systemd. - Copyright (C) 2009-2013 Intel Coproration + Copyright (C) 2009-2013 Intel Corporation Authors: Auke Kok @@ -38,15 +38,13 @@ #include "store.h" #include "svg.h" #include "bootchart.h" +#include "list.h" #define time_to_graph(t) ((t) * arg_scale_x) #define ps_to_graph(n) ((n) * arg_scale_y) #define kb_to_graph(m) ((m) * arg_scale_y * 0.0001) #define to_color(n) (192.0 - ((n) * 192.0)) -#define max(x, y) (((x) > (y)) ? (x) : (y)) -#define min(x, y) (((x) < (y)) ? (x) : (y)) - static char str[8092]; #define svg(a...) do { snprintf(str, 8092, ## a); fputs(str, of); fflush(of); } while (0) @@ -70,16 +68,29 @@ static double idletime = -1.0; static int pfiltered = 0; static int pcount = 0; static int kcount = 0; -static float psize = 0; -static float ksize = 0; -static float esize = 0; +static double psize = 0; +static double ksize = 0; +static double esize = 0; +static struct list_sample_data *sampledata; +static struct list_sample_data *prev_sampledata; +extern struct list_sample_data *head; static void svg_header(void) { - float w; - float h; + double w; + double h; + struct list_sample_data *sampledata_last; + + assert(head); + + sampledata = head; + LIST_FIND_TAIL(link, sampledata, head); + sampledata_last = head; + LIST_FOREACH_BEFORE(link, sampledata, head) { + sampledata_last = sampledata; + } /* min width is about 1600px due to the label */ - w = 150.0 + 10.0 + time_to_graph(sampletime[samples-1] - graph_start); + w = 150.0 + 10.0 + time_to_graph(sampledata_last->sampletime - graph_start); w = ((w < 1600.0) ? 1600.0 : w); /* height is variable based on pss, psize, ksize */ @@ -114,6 +125,7 @@ static void svg_header(void) { svg("\n