266
|
1 #include <stdio.h>
|
|
2 #include <sys/time.h>
|
|
3 #include "TaskManager.h"
|
|
4 #include "SchedTask.h"
|
|
5 #include "Func.h"
|
|
6 #include "FileMapReduce.h"
|
|
7 #include "CeriumGrep.h"
|
|
8
|
|
9 extern void task_init();
|
|
10 void TMend(TaskManager *);
|
|
11 static double st_time;
|
|
12 static double ed_time;
|
|
13 const char* usr_help_str = "";
|
|
14
|
|
15 static double
|
|
16 getTime() {
|
|
17 struct timeval tv;
|
|
18 gettimeofday(&tv, NULL);
|
|
19 return tv.tv_sec + (double)tv.tv_usec*1e-6;
|
|
20 }
|
|
21
|
|
22 int
|
|
23 TMmain(TaskManager *manager, int argc, char *argv[])
|
|
24 {
|
|
25 char *filename = 0;
|
|
26 Search s = grep(argc,argv,true);
|
|
27
|
|
28 FileMapReduce *fmp = new FileMapReduce(manager,TASK_EXEC,TASK_EXEC_DATA_PARALLEL,TASK_PRINT);
|
|
29 filename = fmp->init(argc, argv);
|
|
30 fmp->w->global = (void*)s.tg;
|
|
31 if (filename < 0) {
|
|
32 return -1;
|
|
33 }
|
|
34 fmp->division_out_size = sizeof(void*)*3; // *Result,*blockBegin,*blockEnd
|
|
35 task_init();
|
|
36 st_time = getTime();
|
|
37 fmp->run_start(manager, filename);
|
|
38 manager->set_TMend(TMend);
|
|
39 return 0;
|
|
40 }
|
|
41
|
|
42 void
|
|
43 TMend(TaskManager *manager)
|
|
44 {
|
|
45 ed_time = getTime();
|
|
46 printf("Time: %0.6f\n",ed_time-st_time);
|
|
47 }
|
|
48
|
|
49 /* end */
|