]> www.ginac.de Git - cln.git/blob - src/timing/cl_t_c2.cc
Make @exec_prefix@ usable in shell scripts.
[cln.git] / src / timing / cl_t_c2.cc
1 // constructor cl_timing(cl_ostream).
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_timing.h"
8
9
10 // Implementation.
11
12 static void report_stream (const cl_timing& t)
13 {
14         var const cl_time_consumption usage_end = cl_current_time_consumption();
15         var const cl_time_consumption& usage_start = t.tmp;
16         var cl_time_consumption usage;
17         usage.realtime = usage_end.realtime - usage_start.realtime;
18         usage.usertime = usage_end.usertime - usage_start.usertime;
19
20         var cl_ostream destination =
21 #if defined(CL_IO_STDIO)
22                 (FILE*) t.report_destination;
23 #endif
24 #if defined(CL_IO_IOSTREAM)
25                 *(ostream*) t.report_destination;
26 #endif
27         if (t.comment)
28                 fprint(destination,t.comment);
29         cl_timing_report(destination,usage);
30         fprint(destination,"\n");
31 }
32
33 cl_timing::cl_timing (cl_ostream destination)
34 {
35         report_fn = report_stream;
36 #if defined(CL_IO_STDIO)
37         report_destination = destination;
38 #endif
39 #if defined(CL_IO_IOSTREAM)
40         report_destination = &destination;
41 #endif
42         comment = NULL;
43         tmp = cl_current_time_consumption();
44 }
45
46 cl_timing::cl_timing (const char * msg, cl_ostream destination)
47 {
48         report_fn = report_stream;
49 #if defined(CL_IO_STDIO)
50         report_destination = destination;
51 #endif
52 #if defined(CL_IO_IOSTREAM)
53         report_destination = &destination;
54 #endif
55         comment = msg;
56         tmp = cl_current_time_consumption();
57 }