John, made an interesting post, regarding how many system / library calls a very simple Java program (Hello World) does when it executes. The post can be found here
I decided to try the same in C, and here are the results
First of all, the magnificent piece of code
#include
int main (int argc, char *argv[]) {
printf("Hello world!\n");
return;
}
Now the system call
dstergiou@kl10:~$ strace -c -f -q ./a.out Hello world! % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000029 15 2 open 0.00 0.000000 0 1 read 0.00 0.000000 0 1 write 0.00 0.000000 0 2 close 0.00 0.000000 0 1 execve 0.00 0.000000 0 3 3 access 0.00 0.000000 0 1 brk 0.00 0.000000 0 1 munmap 0.00 0.000000 0 3 mprotect 0.00 0.000000 0 7 mmap2 0.00 0.000000 0 3 fstat64 0.00 0.000000 0 1 set_thread_area ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000029 26 3 total
And finally the library call
dstergiou@kl10:~$ ltrace -c -f ./a.out Hello world! % time seconds usecs/call calls function ------ ----------- ----------- --------- -------------------- 100.00 0.000179 179 1 puts ------ ----------- ----------- --------- -------------------- 100.00 0.000179 1 total
As it is obvious, you have to love Java…
Leave a reply