/[MITgcm]/MITgcm_contrib/heimbach/OpenAD/code_shallow_openad2/timeRatio.c
ViewVC logotype

Annotation of /MITgcm_contrib/heimbach/OpenAD/code_shallow_openad2/timeRatio.c

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


Revision 1.1 - (hide annotations) (download)
Thu Nov 2 01:30:21 2006 UTC (18 years, 8 months ago) by utke
Branch: MAIN
File MIME type: text/plain
baseline

1 utke 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("JU: TIMING: stamp %i: %i.%06i\n",
18     stage,
19     tv_a[stage].tv_sec,
20     tv_a[stage].tv_usec);
21     if (stage>0) {
22     printf("JU: TIMING: delta stamps %i-%i: %i.%06i\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("JU: TIMING: delta stamps %i-%i: %i.%06i\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("JU: TIMING: ratio stamps (%i-%i)/(%i-%i): %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