6 #include "cln/config.h"
7 #include "cln/intparam.h"
15 uintL tv_sec; // seconds since 1970-01-01
16 sintL tv_nsec; // nanoseconds, >= 0, < 1000000000
19 cl_timespec (uintL sec, sintL nsec)
20 : tv_sec (sec), tv_nsec (nsec) {}
23 struct cl_time_duration {
24 uintL tv_sec; // seconds
25 uintL tv_nsec; // nanoseconds
27 cl_time_duration () {}
28 cl_time_duration (uintL sec)
29 : tv_sec (sec), tv_nsec (0) {}
30 cl_time_duration (uintL sec, uintL nsec)
31 : tv_sec (sec), tv_nsec (nsec) {}
34 struct cl_time_consumption {
35 cl_time_duration realtime; // elapsed time
36 cl_time_duration usertime; // system's notion of user time/run time
39 extern const cl_time_duration operator- (const cl_timespec&, const cl_timespec&);
40 extern const cl_timespec operator+ (const cl_timespec&, const cl_time_duration&);
41 extern const cl_timespec operator- (const cl_timespec&, const cl_time_duration&);
42 extern const cl_time_duration operator+ (const cl_time_duration&, const cl_time_duration&);
43 extern const cl_time_duration operator- (const cl_time_duration&, const cl_time_duration&);
45 extern const cl_timespec cl_current_time ();
46 extern const cl_time_consumption cl_current_time_consumption ();
48 // Report a time consumption.
49 // (Should better be a virtual member function of `cl_time_consumption').
50 extern void cl_timing_report (cl_ostream, const cl_time_consumption&);
53 // Constructor, starts the time interval.
54 cl_timing (cl_time_consumption& accumulator);
55 cl_timing (cl_ostream destination = std::cerr);
56 cl_timing (const char *, cl_ostream destination = std::cerr);
57 // Destructor, closes the time interval and does a report.
60 cl_time_consumption tmp;
61 void (*report_fn) (const cl_timing&);
62 void* report_destination;
68 // { CL_TIMING; computation(); }
69 // or { CL_TIMING(accumulator); computation(); }
70 // or { CL_TIMING(cout); computation(); }
71 // The timing interval starts immediately and ends at the closing brace.
72 #define CL_TIMING CL_TIMING1(__LINE__)
73 #define CL_TIMING1(line) CL_TIMING2(line)
74 #define CL_TIMING2(line) cl_timing cl_timing_dummy_##line
78 #endif /* _CL_TIMING_H */