summaryrefslogtreecommitdiff
path: root/overlay/chart.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-17 20:32:58 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-17 20:32:58 +0100
commitcc9de398cf5232e547e9131d72782732a552fc56 (patch)
treefb52f7ff6db8c503c1898698fe2cec7c3a440b13 /overlay/chart.c
parentcbbd55af154f88fdd2c58c0398408f242124b005 (diff)
overlay: Graph per-process requests over time
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay/chart.c')
-rw-r--r--overlay/chart.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/overlay/chart.c b/overlay/chart.c
index f98ba91f..185eaf07 100644
--- a/overlay/chart.c
+++ b/overlay/chart.c
@@ -17,6 +17,7 @@ int chart_init(struct chart *chart, const char *name, int num_samples)
chart->num_samples = num_samples;
chart->range_automatic = 1;
+ chart->stroke_width = 2;
return 0;
}
@@ -25,6 +26,11 @@ void chart_set_mode(struct chart *chart, enum chart_mode mode)
chart->mode = mode;
}
+void chart_set_stroke_width(struct chart *chart, float width)
+{
+ chart->stroke_width = width;
+}
+
void chart_set_stroke_rgba(struct chart *chart, float red, float green, float blue, float alpha)
{
chart->stroke_rgb[0] = red;
@@ -60,6 +66,19 @@ void chart_set_range(struct chart *chart, double min, double max)
chart->range_automatic = 0;
}
+void chart_get_range(struct chart *chart, double *range)
+{
+ int n, max = chart->current_sample;
+ if (max > chart->num_samples)
+ max = chart->num_samples;
+ for (n = 0; n < max; n++) {
+ if (chart->samples[n] < range[0])
+ range[0] = chart->samples[n];
+ else if (chart->samples[n] > range[1])
+ range[1] = chart->samples[n];
+ }
+}
+
void chart_add_sample(struct chart *chart, double value)
{
int pos;
@@ -144,7 +163,7 @@ void chart_draw(struct chart *chart, cairo_t *cr)
cairo_line_to(cr, max, 0);
cairo_identity_matrix(cr);
- cairo_set_line_width(cr, 2);
+ cairo_set_line_width(cr, chart->stroke_width);
switch (chart->mode) {
case CHART_STROKE:
cairo_set_source_rgba(cr, chart->stroke_rgb[0], chart->stroke_rgb[1], chart->stroke_rgb[2], chart->stroke_rgb[3]);
@@ -165,3 +184,8 @@ void chart_draw(struct chart *chart, cairo_t *cr)
}
cairo_restore(cr);
}
+
+void chart_fini(struct chart *chart)
+{
+ free(chart->samples);
+}