7 #include "cl_intparam.h"
13 uintL tv_sec; // seconds since 1970-01-01
14 sintL tv_nsec; // nanoseconds, >= 0, < 1000000000
17 cl_timespec (uintL sec, sintL nsec)
18 : tv_sec (sec), tv_nsec (nsec) {}
21 struct cl_time_duration {
22 uintL tv_sec; // seconds
23 uintL tv_nsec; // nanoseconds
25 cl_time_duration () {}
26 cl_time_duration (uintL sec)
27 : tv_sec (sec), tv_nsec (0) {}
28 cl_time_duration (uintL sec, uintL nsec)
29 : tv_sec (sec), tv_nsec (nsec) {}
32 struct cl_time_consumption {
33 cl_time_duration realtime; // elapsed time
34 cl_time_duration usertime; // system's notion of user time/run time
37 extern const cl_time_duration operator- (const cl_timespec&, const cl_timespec&);
38 extern const cl_timespec operator+ (const cl_timespec&, const cl_time_duration&);
39 extern const cl_timespec operator- (const cl_timespec&, const cl_time_duration&);
40 extern const cl_time_duration operator+ (const cl_time_duration&, const cl_time_duration&);
41 extern const cl_time_duration operator- (const cl_time_duration&, const cl_time_duration&);
43 extern const cl_timespec cl_current_time ();
44 extern const cl_time_consumption cl_current_time_consumption ();
46 // Report a time consumption.
47 // (Should better be a virtual member function of `cl_time_consumption').
48 extern void cl_timing_report (cl_ostream, const cl_time_consumption&);
51 // Constructor, starts the time interval.
52 cl_timing (cl_time_consumption& accumulator);
53 cl_timing (cl_ostream destination = cl_stderr);
54 cl_timing (const char *, cl_ostream destination = cl_stderr);
55 // Destructor, closes the time interval and does a report.
58 cl_time_consumption tmp;
59 void (*report_fn) (const cl_timing&);
60 void* report_destination;
66 // { CL_TIMING; computation(); }
67 // or { CL_TIMING(accumulator); computation(); }
68 // or { CL_TIMING(cl_stdout); computation(); }
69 // The timing interval starts immediately and ends at the closing brace.
70 #define CL_TIMING CL_TIMING1(__LINE__)
71 #define CL_TIMING1(line) CL_TIMING2(line)
72 #define CL_TIMING2(line) cl_timing cl_timing_dummy_##line
74 #endif /* _CL_TIMING_H */