Mercurial > hg > Members > Moririn
diff src/parallel_execution/TimeImpl.cbc @ 364:a0a3301bac4d
Add Time interface
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 29 Jun 2017 18:04:33 +0900 |
parents | src/parallel_execution/time.cbc@23767f714f4a |
children | f1d111e293c4 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/TimeImpl.cbc Thu Jun 29 18:04:33 2017 +0900 @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <sys/time.h> + +#include "../context.h" + +Time* createTimeImpl(struct Context* context) { + struct Time* time = new Time(); + struct TimeImpl* timeImpl = new TimeImpl(); + time->time = (union Data*)timeImpl; + time->start = C_startTime; + time->end = C_endTime; + return time; +} + +__code startTime(struct TimeImpl* time, __code next(...)) { + struct timeval tv; + gettimeofday(&tv, NULL); + + time->time = tv.tv_sec + (double)tv.tv_usec*1e-6; + + goto next(...); +} + +__code endTime(struct TimeImpl* time, __code next(...)) { + struct timeval tv; + gettimeofday(&tv, NULL); + + printf("%0.6f\n", (tv.tv_sec+(double)tv.tv_usec*1e-6) - time->time); + + goto next(...); +}