12 // Round to 3 decimal places.
14 #define CL_HZ_NSECS (1000000000/CL_HZ)
16 void cl_timing_report (cl_ostream stream, const cl_time_consumption& t)
18 var uintL real_sec = t.realtime.tv_sec;
19 var uintL real_msec = (t.realtime.tv_nsec + (CL_HZ_NSECS-1)/2) / CL_HZ_NSECS;
20 if (real_msec >= CL_HZ) { real_msec -= CL_HZ; real_sec += 1; }
21 var uintL user_sec = t.usertime.tv_sec;
22 var uintL user_msec = (t.usertime.tv_nsec + (CL_HZ_NSECS-1)/2) / CL_HZ_NSECS;
23 if (user_msec >= CL_HZ) { user_msec -= CL_HZ; user_sec += 1; }
24 #if defined(CL_IO_STDIO)
25 fprintf(stream, "real time: %4u.%03u s, run time: %4u.%03u s",
26 real_sec, real_msec, user_sec, user_msec);
28 #if defined(CL_IO_IOSTREAM)
29 var char oldfill = stream.fill();
30 var int oldwidth = stream.width();
31 stream << "real time: ";
32 stream.width(4); stream << real_sec; stream << ".";
33 stream.fill('0'); stream.width(3); stream << real_msec;
36 stream << "run time: ";
37 stream.width(4); stream << user_sec; stream << ".";
38 stream.fill('0'); stream.width(3); stream << user_msec;
41 stream.width(oldwidth);