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

Contents of /MITgcm_contrib/heimbach/OpenAD/code_shallow_openad/timeRatio.c

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


Revision 1.1 - (show annotations) (download)
Sun Oct 29 05:19:33 2006 UTC (20 years ago) by utke
Branch: MAIN
File MIME type: text/plain
add timing code

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

  ViewVC Help
Powered by ViewVC 1.1.22