Lines Matching full:ta
85 * @ta: the TimedAverage structure
88 static TimedAverageWindow *current_window(TimedAverage *ta) in current_window() argument
90 return &ta->windows[ta->current]; in current_window()
95 * @ta: the TimedAverage structure
99 void timed_average_init(TimedAverage *ta, QEMUClockType clock_type, in timed_average_init() argument
105 * the interval [ta->period/2,ta->period). By adjusting the in timed_average_init()
109 ta->period = (uint64_t) period * 4 / 3; in timed_average_init()
110 ta->clock_type = clock_type; in timed_average_init()
111 ta->current = 0; in timed_average_init()
113 window_reset(&ta->windows[0]); in timed_average_init()
114 window_reset(&ta->windows[1]); in timed_average_init()
117 ta->windows[0].expiration = now + ta->period / 2; in timed_average_init()
118 ta->windows[1].expiration = now + ta->period; in timed_average_init()
124 * @ta: the TimedAverage structure
128 static void check_expirations(TimedAverage *ta, uint64_t *elapsed) in check_expirations() argument
130 int64_t now = qemu_clock_get_ns(ta->clock_type); in check_expirations()
133 assert(ta->period != 0); in check_expirations()
137 TimedAverageWindow *w = &ta->windows[i]; in check_expirations()
140 update_expiration(w, now, ta->period); in check_expirations()
144 /* Make ta->current point to the oldest window */ in check_expirations()
145 if (ta->windows[0].expiration < ta->windows[1].expiration) { in check_expirations()
146 ta->current = 0; in check_expirations()
148 ta->current = 1; in check_expirations()
153 int64_t remaining = ta->windows[ta->current].expiration - now; in check_expirations()
154 *elapsed = ta->period - remaining; in check_expirations()
160 * @ta: the TimedAverage structure
163 void timed_average_account(TimedAverage *ta, uint64_t value) in timed_average_account() argument
166 check_expirations(ta, NULL); in timed_average_account()
170 TimedAverageWindow *w = &ta->windows[i]; in timed_average_account()
187 * @ta: the TimedAverage structure
190 uint64_t timed_average_min(TimedAverage *ta) in timed_average_min() argument
193 check_expirations(ta, NULL); in timed_average_min()
194 w = current_window(ta); in timed_average_min()
200 * @ta: the TimedAverage structure
203 uint64_t timed_average_avg(TimedAverage *ta) in timed_average_avg() argument
206 check_expirations(ta, NULL); in timed_average_avg()
207 w = current_window(ta); in timed_average_avg()
213 * @ta: the TimedAverage structure
216 uint64_t timed_average_max(TimedAverage *ta) in timed_average_max() argument
218 check_expirations(ta, NULL); in timed_average_max()
219 return current_window(ta)->max; in timed_average_max()
223 * @ta: the TimedAverage structure
227 uint64_t timed_average_sum(TimedAverage *ta, uint64_t *elapsed) in timed_average_sum() argument
230 check_expirations(ta, elapsed); in timed_average_sum()
231 w = current_window(ta); in timed_average_sum()