changeset 1722:264a36d30f7f draft

add time measurement function in fileread
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Mon, 28 Oct 2013 15:25:07 +0900
parents 797e3ec1ca74
children d54e287eeef3
files example/fileread/main.cc
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/example/fileread/main.cc	Mon Oct 28 13:35:17 2013 +0900
+++ b/example/fileread/main.cc	Mon Oct 28 15:25:07 2013 +0900
@@ -2,11 +2,14 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 #include "TaskManager.h"
 #include "Func.h"
 
 extern void task_init(void);
 
+static double st_time;
+static double ed_time;
 static int spe_num = 1;
 static CPU_TYPE spe_cpu = SPE_ANY;
 static int ONE_TASK_SIZE = 4096 * 4;
@@ -14,7 +17,22 @@
 extern TaskManager *manager;
 const char *usr_help_str = "Usage: ./fileread [-cpu cpu_num] [-file filename]\n\
                             -cpu    Number of SPE (default 1) \n\
-                            -file   Opne file";
+                            -file   Opne file\n";
+
+static double
+getTime(){
+    struct timeval tv;
+    gettimeofday(&tv,NULL);
+    return tv.tv_sec + (double)tv.tv_usec*1e-6;
+}
+
+void
+TMend(TaskManager *manager)
+{
+    ed_time = getTime();
+    printf("Time: %0.6f\n",ed_time-st_time);
+}
+
 
 static char*
 init(int argc, char **argv)
@@ -84,7 +102,9 @@
     }
 
     task_init();
+    st_time = getTime();
     run_start(manager, filename);
+    manager->set_TMend(TMend);
 
     return 0;
 }