Mercurial > hg > Game > Cerium
view example/many_task/main.cc @ 203:1eba8570808c draft
fix CreateSpan::run
author | gongo@localhost.localdomain |
---|---|
date | Mon, 26 Jan 2009 18:30:35 +0900 |
parents | 028ffc9c0375 |
children | bfdd037aee21 |
line wrap: on
line source
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys/time.h> #include "TaskManager.h" #include "Func.h" extern void task_init(void); int data_size = 1200; double getTime(); char *help_str = "Usage: ./sort [-cpu spe_num] [-length data_length]\n \ -cpu Number of SPE used (default 1) \n \ -length Sorted number of data (default 1200)"; int init(int argc, char **argv) { for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-length") == 0) { data_size = atoi(argv[++i]); } if (strcmp(argv[i], "--help") == 0) { printf("%s\n", help_str); return -1; } } return 0; } int main(int argc, char *argv[]) { // 計測用 double st_time, ed_time; HTask *runLoop; if (init(argc, argv) < 0) { return -1; } task_init(); runLoop = manager->create_task(TASK_MAIN); printf("main spenum: %d\n",spenum); runLoop->add_param(spenum); runLoop->add_param(data_size); runLoop->spawn(); // Start st_time = getTime(); manager->run(); ed_time = getTime(); printf("Time: %0.6f\n",ed_time-st_time); delete manager; FINISH: return 0; } double getTime() { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec + (double)tv.tv_usec*1e-6; }