/[MITgcm]/MITgcm/tools/OAD_support/timeRatio.c
ViewVC logotype

Annotation of /MITgcm/tools/OAD_support/timeRatio.c

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


Revision 1.1 - (hide annotations) (download)
Thu Sep 20 23:12:48 2012 UTC (11 years, 7 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64o, checkpoint64a, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint64n, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64c, checkpoint64g, checkpoint64f, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64, checkpoint65, checkpoint64j, checkpoint64m, checkpoint64l, HEAD
File MIME type: text/plain
* Merge OAD_support from MITgcm_contrib/heimbach/OpenAD/OAD_support/
  to tools/OAD_support/
* Adjust genmake2 to reflect path change (attempt with ${OADTOOLS})
* Adjust insertTemplateDir.bash to reflect path change
Seems to work.

1 heimbach 1.1 #include <sys/time.h>
2     #include <stdio.h>
3    
4     void timeratio_() {
5     /*
6     three invocations produce
7     the ratio of the timedifference of
8     the 3rd vs. the 2nd invocation over
9     the difference of the 2nd vs. the 1st invocation
10     */
11     static short stage=0;
12     #define tvCount 3
13     static struct timeval tv_a[tvCount];
14     double deltaThis, deltaPrevious;
15     if (stage<tvCount)
16     gettimeofday(&(tv_a[stage]),0);
17     printf("OAD: TIMING: stamp %u: %lu.%06lu\n",
18     stage,
19     tv_a[stage].tv_sec,
20     tv_a[stage].tv_usec);
21     if (stage>0) {
22     printf("OAD: TIMING: delta stamps %u-%u: %lu.%06lu\n",
23     stage,
24     stage-1,
25     (tv_a[stage].tv_usec<tv_a[stage-1].tv_usec)?tv_a[stage].tv_sec-tv_a[stage-1].tv_sec-1:tv_a[stage].tv_sec-tv_a[stage-1].tv_sec,
26     (tv_a[stage].tv_usec<tv_a[stage-1].tv_usec)?1000000-(tv_a[stage-1].tv_usec-tv_a[stage].tv_usec):tv_a[stage].tv_usec-tv_a[stage-1].tv_usec);
27     }
28     if (stage>1) {
29     printf("OAD: TIMING: delta stamps %u-%u: %lu.%06lu\n",
30     stage,
31     0,
32     (tv_a[stage].tv_usec<tv_a[0].tv_usec)?tv_a[stage].tv_sec-tv_a[0].tv_sec-1:tv_a[stage].tv_sec-tv_a[0].tv_sec,
33     (tv_a[stage].tv_usec<tv_a[0].tv_usec)?1000000-(tv_a[0].tv_usec-tv_a[stage].tv_usec):tv_a[stage].tv_usec-tv_a[0].tv_usec);
34     }
35     if (stage==tvCount-1 && stage>1) {
36     deltaThis=(tv_a[stage].tv_usec<tv_a[stage-1].tv_usec)?tv_a[stage].tv_sec-tv_a[stage-1].tv_sec-1:tv_a[stage].tv_sec-tv_a[stage-1].tv_sec;
37     deltaThis*=1.0e6;
38     deltaThis+=(tv_a[stage].tv_usec<tv_a[stage-1].tv_usec)?1000000-(tv_a[stage-1].tv_usec-tv_a[stage].tv_usec):tv_a[stage].tv_usec-tv_a[stage-1].tv_usec;
39     deltaPrevious=(tv_a[stage-1].tv_usec<tv_a[stage-2].tv_usec)?tv_a[stage-1].tv_sec-tv_a[stage-2].tv_sec-1:tv_a[stage-1].tv_sec-tv_a[stage-2].tv_sec;
40     deltaPrevious*=1.0e6;
41     deltaPrevious+=(tv_a[stage-1].tv_usec<tv_a[stage-2].tv_usec)?1000000-(tv_a[stage-2].tv_usec-tv_a[stage-1].tv_usec):tv_a[stage-1].tv_usec-tv_a[stage-2].tv_usec;
42     printf("OAD: TIMING: ratio stamps (%u-%u)/(%u-%u): %e/%e=%e\n",
43     stage,
44     stage-1,
45     stage-1,
46     stage-2,
47     deltaThis,
48     deltaPrevious,
49     deltaThis/deltaPrevious);
50     stage=0;
51     }
52     else
53     stage++;
54     }

  ViewVC Help
Powered by ViewVC 1.1.22