Thursday, October 13, 2016

C (programming language): time (Unix): The Duration of Execution of Printing Out 1 to 120,000,000

Command:

$ cat 120million.c


Result:

#include<stdio.h>

int main()
{
for (long n=1; n<=120000000; n++){
printf("%ld\n", n);
}
}


Command:

$ gcc 120million.c
$ time ./a.out


Result:

1
2
3
...
119999998
119999999
120000000

real 3m10.250s
user 0m40.043s
sys 1m5.333s