steadystate: more cleanups
[fio.git] / steadystate.h
1 #ifndef FIO_STEADYSTATE_H
2 #define FIO_STEADYSTATE_H
3
4 #include "thread_options.h"
5
6 extern void steadystate_check(void);
7 extern void steadystate_setup(void);
8 extern void steadystate_alloc(struct thread_data *);
9
10 extern bool steadystate;
11
12 /*
13  * For steady state detection
14  */
15 struct steadystate_data {
16         double limit;
17         unsigned long long dur;
18         unsigned long long ramp_time;
19         bool check_iops;
20         bool check_slope;
21         bool pct;
22
23         int attained;
24         int last_in_group;
25         int ramp_time_over;
26
27         unsigned int head;
28         unsigned int tail;
29         unsigned long *iops_data;
30         unsigned long *bw_data;
31
32         double slope;
33         double criterion;
34         double deviation;
35
36         unsigned long long sum_y;
37         unsigned long long sum_x;
38         unsigned long long sum_x_sq;
39         unsigned long long sum_xy;
40         unsigned long long oldest_y;
41
42         struct timeval prev_time;
43         unsigned long long prev_iops;
44         unsigned long long prev_bytes;
45 };
46
47 enum {
48         FIO_STEADYSTATE_IOPS    = 0,
49         FIO_STEADYSTATE_IOPS_SLOPE,
50         FIO_STEADYSTATE_BW,
51         FIO_STEADYSTATE_BW_SLOPE,
52 };
53
54 static inline bool steadystate_check_slope(struct thread_options *o)
55 {
56         return o->ss == FIO_STEADYSTATE_IOPS_SLOPE ||
57                 o->ss == FIO_STEADYSTATE_BW_SLOPE;
58 }
59
60 static inline bool steadystate_check_iops(struct thread_options *o)
61 {
62         return o->ss == FIO_STEADYSTATE_IOPS ||
63                 o->ss == FIO_STEADYSTATE_IOPS_SLOPE;
64 }
65
66 #endif