diff src/parallel_execution/time.cbc @ 277:9d671e63df74

generate extern
author mir3636
date Thu, 02 Feb 2017 18:29:50 +0900
parents src/parallel_execution/time.c@63ab65b28466
children 23767f714f4a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parallel_execution/time.cbc	Thu Feb 02 18:29:50 2017 +0900
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <sys/time.h>
+
+#include "context.h"
+#include "origin_cs.h"
+
+__code start_time(struct Context* context, struct Time* time) {
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+
+    time->time = tv.tv_sec + (double)tv.tv_usec*1e-6;
+
+    goto meta(context, time->next);
+}
+
+__code start_time_stub(struct Context* context) {
+    goto start_time(context, &context->data[D_Time]->Time);
+}
+
+__code end_time(struct Context* context, struct Time* time) {
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+
+    printf("%0.6f\n", (tv.tv_sec+(double)tv.tv_usec*1e-6) - time->time);
+
+    goto meta(context, time->next);
+}
+
+__code end_time_stub(struct Context* context) {
+    goto end_time(context, Gearef(context, Time));
+}