Mercurial > hg > Game > Cerium
comparison example/fileread/main.cc @ 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 | 5a294d8e5643 |
comparison
equal
deleted
inserted
replaced
1721:797e3ec1ca74 | 1722:264a36d30f7f |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 #include <string.h> | 3 #include <string.h> |
4 #include <sys/stat.h> | 4 #include <sys/stat.h> |
5 #include <sys/time.h> | |
5 #include "TaskManager.h" | 6 #include "TaskManager.h" |
6 #include "Func.h" | 7 #include "Func.h" |
7 | 8 |
8 extern void task_init(void); | 9 extern void task_init(void); |
9 | 10 |
11 static double st_time; | |
12 static double ed_time; | |
10 static int spe_num = 1; | 13 static int spe_num = 1; |
11 static CPU_TYPE spe_cpu = SPE_ANY; | 14 static CPU_TYPE spe_cpu = SPE_ANY; |
12 static int ONE_TASK_SIZE = 4096 * 4; | 15 static int ONE_TASK_SIZE = 4096 * 4; |
13 | 16 |
14 extern TaskManager *manager; | 17 extern TaskManager *manager; |
15 const char *usr_help_str = "Usage: ./fileread [-cpu cpu_num] [-file filename]\n\ | 18 const char *usr_help_str = "Usage: ./fileread [-cpu cpu_num] [-file filename]\n\ |
16 -cpu Number of SPE (default 1) \n\ | 19 -cpu Number of SPE (default 1) \n\ |
17 -file Opne file"; | 20 -file Opne file\n"; |
21 | |
22 static double | |
23 getTime(){ | |
24 struct timeval tv; | |
25 gettimeofday(&tv,NULL); | |
26 return tv.tv_sec + (double)tv.tv_usec*1e-6; | |
27 } | |
28 | |
29 void | |
30 TMend(TaskManager *manager) | |
31 { | |
32 ed_time = getTime(); | |
33 printf("Time: %0.6f\n",ed_time-st_time); | |
34 } | |
35 | |
18 | 36 |
19 static char* | 37 static char* |
20 init(int argc, char **argv) | 38 init(int argc, char **argv) |
21 { | 39 { |
22 | 40 |
82 if (filename < 0) { | 100 if (filename < 0) { |
83 return -1; | 101 return -1; |
84 } | 102 } |
85 | 103 |
86 task_init(); | 104 task_init(); |
105 st_time = getTime(); | |
87 run_start(manager, filename); | 106 run_start(manager, filename); |
107 manager->set_TMend(TMend); | |
88 | 108 |
89 return 0; | 109 return 0; |
90 } | 110 } |