xref: /iperf/src/timer.h (revision 8a0cc100)
1 /*
2  * Copyright (c) 2009-2011, The Regents of the University of California,
3  * through Lawrence Berkeley National Laboratory (subject to receipt of any
4  * required approvals from the U.S. Dept. of Energy).  All rights reserved.
5  *
6  * This code is distributed under a BSD style license, see the LICENSE file
7  * for complete information.
8  */
9 
10 #ifndef __TIMER_H
11 #define __TIMER_H
12 
13 #include <time.h>
14 #include <sys/time.h>
15 
16 struct timer {
17     struct timeval begin;
18     struct timeval end;
19     int (*expired)(struct timer *timer);
20 };
21 
22 struct timer *new_timer(time_t sec, suseconds_t usec);
23 
24 int delay(int64_t ns);
25 
26 double timeval_to_double(struct timeval *tv);
27 
28 int timeval_equals(struct timeval *tv0, struct timeval *tv1);
29 
30 double timeval_diff(struct timeval *tv0, struct timeval *tv1);
31 
32 int update_timer(struct timer *tp, time_t sec, suseconds_t usec);
33 
34 int64_t timer_remaining(struct timer *tp);
35 
36 void free_timer(struct timer *tp);
37 
38 int timer_expired(struct timer *);
39 
40 void cpu_util(double *);
41 
42 #endif
43