Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/time.h>
- #include <sys/resource.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <string.h>
- #include <errno.h>
- int main (int argc, char *const argv[], char *const envp[])
- {
- struct rusage stat;
- pid_t is_parent;
- int iteration = strtol(argv[1],NULL,0);
- char * commande = argv[2];
- for (int i = 0 ; i < iteration ; i++){
- system(commande);
- }
- if (getrusage(RUSAGE_CHILDREN, &stat) == -1){
- fprintf(stderr, "pb ressources : %s\n", strerror(errno));
- exit(4);
- }
- printf("user CPU time : %ld:%.5ld seconds \n", stat.ru_utime.tv_sec/iteration, stat.ru_utime.tv_usec/iteration);
- printf("system CPU time : %ld:%.5ld seconds \n", stat.ru_stime.tv_sec/iteration, stat.ru_stime.tv_usec/iteration);
- exit(0);
- }
- pute
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement