# HG changeset patch # User Masataka Kohagura # Date 1382941507 -32400 # Node ID 264a36d30f7fce69d996b705a65856b37350f4f2 # Parent 797e3ec1ca749208fda8a5d46e01dab1d95b053c add time measurement function in fileread diff -r 797e3ec1ca74 -r 264a36d30f7f example/fileread/main.cc --- 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 #include #include +#include #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; }