/* Test how much time is needed for a process/thread creation Author: Gergely Czuczy */ #include #include #include #include #include #include #include #include double timeval2double(struct timeval *_tv); void *threadfunc(void *); /* ================================ int main(int argc, char *argv[]) ================================ */ int main(int argc, char *argv[]) { unsigned int i; unsigned int samples; unsigned int forkfailures(0), threadfailures(0); double totalforktime(0),totalthreadtime(0), forktime, threadtime; struct timeval begin,end,diff; pid_t childpid; pthread_t thread; if ( argc != 2 ) { printf("Usage:\n\t%s \n", argv[0]); return EXIT_FAILURE; } // we get the number of samples to take samples = atoi(argv[1]); // test the forks printf("\n"); for ( i=0; itv_usec; ret /= 1000000; ret += _tv->tv_sec; ret *= 1000; return ret; }