iowatcher: Make seconds unsigned
[blktrace.git] / iowatcher / plot.h
... / ...
CommitLineData
1/*
2 * Copyright (C) 2012 Fusion-io
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 *
17 */
18#ifndef __IOWATCH_PLOT__
19#define __IOWATCH_PLOT__
20#define MAX_TICKS 10
21
22#include "list.h"
23
24typedef __u64 u64;
25typedef __u32 u32;
26typedef __u16 u16;
27
28
29/* values for the plot direction field */
30#define PLOT_DOWN 0
31#define PLOT_ACROSS 1
32
33struct plot {
34 int fd;
35
36 /* svg style y = 0 is the top of the graph */
37 int start_y_offset;
38
39 /* abs coords of the start of X start of the plot */
40 int start_x_offset;
41
42 int add_xlabel;
43 int no_legend;
44
45 /*
46 * these two are for anyone that wants
47 * to add a plot after this one, it tells
48 * them how much space we took up
49 */
50 int total_height;
51 int total_width;
52 char **legend_lines;
53 int legend_index;
54 int num_legend_lines;
55 int direction;
56
57 /*
58 * timeline is a vertical line through line graphs that
59 * is used by the movie mode to show where in the graph
60 * our current frame lives
61 */
62 int timeline;
63};
64
65struct graph_line_pair {
66 u64 count;
67 u64 sum;
68};
69
70struct graph_line_data {
71 /* beginning of an interval displayed by this graph */
72 unsigned int min_seconds;
73
74 /* end of an interval displayed by this graph */
75 unsigned int max_seconds;
76
77 unsigned int stop_seconds;
78
79 /* Y max */
80 u64 max;
81
82 /* label for this graph */
83 char *label;
84 struct graph_line_pair data[];
85};
86
87struct graph_dot_data {
88 u64 min_offset;
89 u64 max_offset;
90 u64 max_bank;
91 u64 max_bank_offset;
92 u64 total_ios;
93 u64 total_bank_ios;
94
95 int add_bank_ios;
96
97 /* in pixels, number of rows in our bitmap */
98 int rows;
99 /* in pixels, number of cols in our bitmap */
100 int cols;
101
102 /* beginning of an interval displayed by this graph */
103 int min_seconds;
104
105 /* end of an interval displayed by this graph */
106 unsigned int max_seconds;
107 unsigned int stop_seconds;
108
109 /* label for the legend */
110 char *label;
111
112 /* color for plotting data */
113 char *color;
114
115 /* bitmap, one bit for each cell to light up */
116 unsigned char data[];
117};
118
119struct pid_plot_history {
120 double history_max;
121 int history_len;
122 int num_used;
123 char *color;
124 double *history;
125};
126
127struct plot_history {
128 struct list_head list;
129 int pid_history_count;
130 int col;
131 struct pid_plot_history **read_pid_history;
132 struct pid_plot_history **write_pid_history;
133};
134
135char *pick_color(void);
136char *pick_fio_color(void);
137char *pick_cpu_color(void);
138void reset_cpu_color(void);
139int svg_io_graph(struct plot *plot, struct graph_dot_data *gdd);
140int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color, int thresh1, int thresh2);
141struct graph_line_data *alloc_line_data(unsigned int min_seconds, unsigned int max_seconds, unsigned int stop_seconds);
142void free_line_data(struct graph_line_data *gld);
143struct graph_dot_data *alloc_dot_data(unsigned int min_seconds, unsigned int max_seconds, u64 min_offset, u64 max_offset, unsigned int stop_seconds, char *color, char *label);
144void free_dot_data(struct graph_dot_data *gdd);
145void set_gdd_bit(struct graph_dot_data *gdd, u64 offset, double bytes, double time);
146void print_gdd(struct graph_dot_data *gdd);
147void write_svg_header(int fd);
148struct plot *alloc_plot(void);
149int close_plot(struct plot *plot);
150int close_plot_no_height(struct plot *plot);
151void setup_axis(struct plot *plot);
152void set_xticks(struct plot *plot, int num_ticks, int first, int last);
153void set_yticks(struct plot *plot, int num_ticks, int first, int last, char *units);
154void set_plot_title(struct plot *plot, char *title);
155void set_plot_label(struct plot *plot, char *label);
156void set_xlabel(struct plot *plot, char *label);
157void set_ylabel(struct plot *plot, char *label);
158void scale_line_graph_bytes(u64 *max, char **units, u64 factor);
159void scale_line_graph_time(u64 *max, char **units);
160void write_drop_shadow(struct plot *plot);
161void write_drop_shadow_line(struct plot *plot);
162void svg_write_legend(struct plot *plot);
163void svg_add_legend(struct plot *plot, char *text, char *extra, char *color);
164void svg_alloc_legend(struct plot *plot, int num_lines);
165void set_legend_width(int longest_str);
166void set_rolling_avg(int rolling);
167void svg_free_legend(struct plot *plot);
168void set_io_graph_scale(int scale);
169void set_plot_output(struct plot *plot, char *filename);
170void set_graph_size(int width, int height);
171void get_graph_size(int *width, int *height);
172int svg_io_graph_movie(struct graph_dot_data *gdd, struct pid_plot_history *ph, int col);
173int svg_io_graph_movie_array(struct plot *plot, struct pid_plot_history *ph);
174void svg_write_time_line(struct plot *plot, int col);
175void set_graph_height(int h);
176void set_graph_width(int w);
177int close_plot_file(struct plot *plot);
178int svg_io_graph_movie_array_spindle(struct plot *plot, struct pid_plot_history *ph);
179void rewind_spindle_steps(int num);
180void setup_axis_spindle(struct plot *plot);
181int close_plot_col(struct plot *plot);
182
183#endif