4 #include "base/cl_sysdep.h"
7 #include "cln/timing.h"
14 // Round to 3 decimal places.
16 #define CL_HZ_NSECS (1000000000/CL_HZ)
18 void cl_timing_report (std::ostream& stream, const cl_time_consumption& t)
20 var uintL real_sec = t.realtime.tv_sec;
21 var uintL real_msec = (t.realtime.tv_nsec + (CL_HZ_NSECS-1)/2) / CL_HZ_NSECS;
22 if (real_msec >= CL_HZ) { real_msec -= CL_HZ; real_sec += 1; }
23 var uintL user_sec = t.usertime.tv_sec;
24 var uintL user_msec = (t.usertime.tv_nsec + (CL_HZ_NSECS-1)/2) / CL_HZ_NSECS;
25 if (user_msec >= CL_HZ) { user_msec -= CL_HZ; user_sec += 1; }
26 var char oldfill = stream.fill();
27 var int oldwidth = stream.width();
28 stream << "real time: ";
29 stream.width(4); stream << real_sec; stream << ".";
30 stream.fill('0'); stream.width(3); stream << real_msec;
33 stream << "run time: ";
34 stream.width(4); stream << user_sec; stream << ".";
35 stream.fill('0'); stream.width(3); stream << user_msec;
38 stream.width(oldwidth);