static void do_cmd(char *cmd) { struct tms tmsstart, tmsend; clock_t start,end; int status; printf("\ncommand: %s\n",cmd); if((start = times(&tmsstart)) < 0){ perror("times start error"); exit(EXIT_FAILURE); } if((status = system(cmd)) < 0){ perror("system error"); exit(EXIT_FAILURE); } if((end = times(&tmsend)) < 0){ perror("time end error"); exit(EXIT_FAILURE); } pr_times(end-start,&tmsstart, &tmsend); printf("system cammand status: %d",status); }
void testAppend(){ OsFile id;/* I don't like the implementation since OSFile need to create by myself*/ int Readonly; int i,nPages; double time; char * buf=sqlite3Malloc(config.pagesize); rc = sqlite3OsOpenReadWrite( config.datfile, &id, &Readonly); errorHandle(rc, "can't open the file"); for(nPages=1; nPages<=config.pagenum; nPages++){ printf("append %d pages!\n",nPages); start_timer(); for(i=0;i<nPages;i++){ sqlite3Randomness(config.pagesize, buf); rc = sqlite3OsWrite(&id, buf, config.pagesize); errorHandle(rc, "write error"); } time = get_timer(); pr_times(config.recordfile, time); } rc= sqlite3OsClose(&id); errorHandle(rc, "can't close the file"); //TODO can't find the defintion, do it later //sqlite3Free((void *)buf); }
static void do_cmd(char *cmd) { struct tms tmsstart; struct tms tmsend; clock_t start; clock_t end; int status; printf("\ncommand: %s\n", cmd); if ((start = times(&tmsstart)) == -1) { err_sys("strart times error"); } if ((status = system(cmd)) < 0) // { err_sys("system error"); } if ((end = times(&tmsend)) == -1) { err_sys("end times error"); } pr_times(end-start, &tmsstart, &tmsend); // pr_exit(status); }
static void do_cmd(char *cmd) { struct tms tms_start, tms_end; clock_t start, end; int status; printf("\ncommand:%s\n", cmd); if((start = times(&tms_start)) == -1) { perror("times"); exit(1); } if((status = system(cmd)) < 0) { printf("system error\n"); exit(1); } if((end = times(&tms_end)) == -1) { perror("times2"); exit(1); } pr_times(end-start, &tms_start, &tms_end); pr_exit(status); }
void do_cmd(const char*cmd) { struct tms tmstart, tmsend; clock_t start, end;int status; printf("\ncommand: %s\n",cmd); if((start=times(&tmstart))==-1) err_sys("times error\n"); if((status=system(cmd))<0) err_sys("system() error\n"); if((end=times(&tmsend))==-1) err_sys("times error\n"); pr_times(end-start,&tmstart,&tmsend); }
static void do_cmd(char *cmd) /* execute and time the "cmd" */ { struct tms tmsstart, tmsend; clock_t start, end; int status; printf("\ncommand: %s\n", cmd); if ((start = times(&tmsstart)) == -1) /* starting values */ err_sys("times error"); if ((status = system(cmd)) < 0) /* execute command */ err_sys("system() error"); if ((end = times(&tmsend)) == -1) /* ending values */ err_sys("times error"); pr_times(end-start, &tmsstart, &tmsend); pr_exit(status); }
static void do_cmd(const char *cmd) { struct tms tmsstart,tmsend; clock_t start,end; int status; fprintf(stderr, "\ncommand %s\n",cmd); if((start=times(&tmsstart))==-1) err_sys("times error"); if((status=system(cmd))<0) err_sys("system error"); if((end=times(&tmsend))==-1) err_sys("times error"); pr_times(end-start,&tmsstart,&tmsend); pr_exit(status); }
/* * execute and time the "cmd" */ static void do_cmd(char *cmd) { #if 0 struct tms { clock_t tms_utime; /* user time */ clock_t tms_stime; /* system time */ clock_t tms_cutime; /* user time of children */ clock_t tms_cstime; /* system time of children */ }; #endif struct tms tmsstart, tmsend; clock_t start, end; int status; fprintf(stdout, "\ncommand: %s\n", cmd); //clock_t times(struct tms *buf); if((start = times(&tmsstart)) == -1){ /* starting values */ perror("times error"); exit(1); } //int system(const char *command); if((status = system(cmd)) < 0){ perror("system() error"); exit(1); } if((end = times(&tmsend)) == -1){ perror("times error"); exit(1); } pr_times(end-start, &tmsstart, &tmsend); pr_exit(status); }