File indexing completed on 2026-05-19 08:08:33
0001
0002
0003 #ifndef _CL_TIMING_H
0004 #define _CL_TIMING_H
0005
0006 #include "cln/config.h"
0007 #include "cln/intparam.h"
0008 #include "cln/types.h"
0009
0010 #include "cln/io.h"
0011
0012 namespace cln {
0013
0014 struct cl_timespec {
0015 uintL tv_sec;
0016 sintL tv_nsec;
0017
0018 cl_timespec () {}
0019 cl_timespec (uintL sec, sintL nsec)
0020 : tv_sec (sec), tv_nsec (nsec) {}
0021 };
0022
0023 struct cl_time_duration {
0024 uintL tv_sec;
0025 uintL tv_nsec;
0026
0027 cl_time_duration () {}
0028 cl_time_duration (uintL sec)
0029 : tv_sec (sec), tv_nsec (0) {}
0030 cl_time_duration (uintL sec, uintL nsec)
0031 : tv_sec (sec), tv_nsec (nsec) {}
0032 };
0033
0034 struct cl_time_consumption {
0035 cl_time_duration realtime;
0036 cl_time_duration usertime;
0037 };
0038
0039 extern const cl_time_duration operator- (const cl_timespec&, const cl_timespec&);
0040 extern const cl_timespec operator+ (const cl_timespec&, const cl_time_duration&);
0041 extern const cl_timespec operator- (const cl_timespec&, const cl_time_duration&);
0042 extern const cl_time_duration operator+ (const cl_time_duration&, const cl_time_duration&);
0043 extern const cl_time_duration operator- (const cl_time_duration&, const cl_time_duration&);
0044
0045 extern const cl_timespec cl_current_time ();
0046 extern const cl_time_consumption cl_current_time_consumption ();
0047
0048
0049
0050 extern void cl_timing_report (std::ostream&, const cl_time_consumption&);
0051
0052 struct cl_timing {
0053
0054 cl_timing (cl_time_consumption& accumulator);
0055 cl_timing (std::ostream& destination = std::cerr);
0056 cl_timing (const char *, std::ostream& destination = std::cerr);
0057
0058 ~cl_timing ();
0059
0060 cl_time_consumption tmp;
0061 void (*report_fn) (const cl_timing&);
0062 void* report_destination;
0063 const char * comment;
0064 };
0065
0066
0067
0068
0069
0070
0071
0072 #define CL_TIMING CL_TIMING1(__LINE__)
0073 #define CL_TIMING1(line) CL_TIMING2(line)
0074 #define CL_TIMING2(line) cl_timing cl_timing_dummy_##line
0075
0076 }
0077
0078 #endif