/[MITgcm]/MITgcm/eesupp/src/timer_stats.c
ViewVC logotype

Contents of /MITgcm/eesupp/src/timer_stats.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Tue Oct 10 00:10:08 2006 UTC (17 years, 8 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint59, checkpoint58y_post, checkpoint58t_post, checkpoint58w_post, checkpoint58q_post, mitgcm_mapl_00, checkpoint58r_post, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint59c, checkpoint59b, checkpoint59h, checkpoint58v_post, checkpoint58x_post, checkpoint58u_post, checkpoint58s_post
Changes since 1.2: +4 -4 lines
File MIME type: text/plain
Changing routine names to avoid mangled name mangling and adding
in Mark Hadfield fix for -ignoretime genmake2 option.

1 #include <sys/types.h>
2 #include <sys/times.h>
3 #include <sys/time.h>
4 #include <unistd.h>
5 /* Here, we get the definition of the FC_NAMEMANGLE() macro. */
6 #include "FC_NAMEMANGLE.h"
7
8 static long clktck = 0;
9 static double invclktck = 0.0;
10
11 double FC_NAMEMANGLE(cusertime) (void);
12 double FC_NAMEMANGLE(csystemtime) (void);
13 double FC_NAMEMANGLE(timenow) ();
14 void init_timer();
15
16 void init_timer()
17 {
18 clktck = sysconf(_SC_CLK_TCK);
19 invclktck = 1.0/clktck;
20 return;
21 }
22
23 double FC_NAMEMANGLE(cusertime) (void)
24 {
25 clock_t blabla;
26 struct tms timest;
27 /* This is useless overhead but we'd need to call init_timer() elsewhere */
28 if (clktck == 0) init_timer();
29
30 blabla = times(&timest);
31 return invclktck*timest.tms_utime;
32
33 }
34
35 double FC_NAMEMANGLE(csystemtime) (void)
36 {
37 clock_t blabla;
38 struct tms timest;
39 /* This is useless overhead but we'd need to call init_timer() elsewhere */
40 if (clktck == 0) init_timer();
41
42 blabla = times(&timest);
43 return invclktck*timest.tms_stime;
44
45 }
46
47
48
49 double FC_NAMEMANGLE(timenow) (void)
50 {
51 struct timeval timestr;
52 void *Tzp=0;
53 gettimeofday(&timestr, Tzp);
54
55 return (double)timestr.tv_sec+1.0E-06*(double)timestr.tv_usec;
56 }
57

  ViewVC Help
Powered by ViewVC 1.1.22