File indexing completed on 2018-03-02 18:45:10 UTC
view on githubraw file Latest commit 8702af1f on 2012-09-20 23:12:48 UTC
8702af1f36 Patr*0001 #include <sys/time.h>
0002 #include <stdio.h>
0003
0004 void timeratio_() {
0005
0006
0007
0008
0009
0010
0011 static short stage=0;
0012 #define tvCount 3
0013 static struct timeval tv_a[tvCount];
0014 double deltaThis, deltaPrevious;
0015 if (stage<tvCount)
0016 gettimeofday(&(tv_a[stage]),0);
0017 printf("OAD: TIMING: stamp %u: %lu.%06lu\n",
0018 stage,
0019 tv_a[stage].tv_sec,
0020 tv_a[stage].tv_usec);
0021 if (stage>0) {
0022 printf("OAD: TIMING: delta stamps %u-%u: %lu.%06lu\n",
0023 stage,
0024 stage-1,
0025 (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,
0026 (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);
0027 }
0028 if (stage>1) {
0029 printf("OAD: TIMING: delta stamps %u-%u: %lu.%06lu\n",
0030 stage,
0031 0,
0032 (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,
0033 (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);
0034 }
0035 if (stage==tvCount-1 && stage>1) {
0036 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;
0037 deltaThis*=1.0e6;
0038 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;
0039 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;
0040 deltaPrevious*=1.0e6;
0041 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;
0042 printf("OAD: TIMING: ratio stamps (%u-%u)/(%u-%u): %e/%e=%e\n",
0043 stage,
0044 stage-1,
0045 stage-1,
0046 stage-2,
0047 deltaThis,
0048 deltaPrevious,
0049 deltaThis/deltaPrevious);
0050 stage=0;
0051 }
0052 else
0053 stage++;
0054 }