Skip to content

Commit

Permalink
three different time loops of know lenght
Browse files Browse the repository at this point in the history
  • Loading branch information
Srinath Vadlamani committed Jan 2, 2018
1 parent e743d91 commit 99ecc61
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions codingTests/cCodes/threeTimeLoops.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,43 @@ int main(int argc, char** argv) {
//think about how these intervals are to be treated across ranks
//maybe do an all reduce of loop times per rank as a runtime option

time_t mpiendwait, compendwait, endtime,looptime;
time_t mpiendwait, compendwait, looptime;
time_t loop1time, loop2time, loop3time;
time_t endtime;
time_t starttime = time(NULL);
time_t delay = 10; // end loop after this time has elapsed

endtime = starttime + delay;
time_t delay1 = 10; // end loop after this time has elapsed
time_t delay2 = 5; // end loop after this time has elapsed
time_t delay3 = 15; // end loop after this time has elapsed

printf("start time is : %s", ctime(&starttime));

// section 1
looptime = starttime;
endtime = starttime + delay1;
while (looptime < endtime)
{
looptime = time(NULL);
}
printf("end loop 1 time is %s", ctime(&endtime));

// section 2
starttime = time(NULL);
looptime = starttime;
endtime = starttime + delay2;
while (looptime < endtime)
{
looptime = time(NULL);
}
printf("end loop 2 time is %s", ctime(&endtime));


// section 3
starttime = time(NULL);
looptime = starttime;
endtime = starttime + delay3;
while (looptime < endtime)
{
looptime = time(NULL);
}
printf("end time is %s", ctime(&endtime));
printf("end loop 3 time is %s", ctime(&endtime));
}

0 comments on commit 99ecc61

Please sign in to comment.