As dvnrrs suggested, I wrote the following code
:
#include <pthread.h>
int main(void) {
int i;
for (i = 0; i < 100000; i++) {
pthread_self();
}
}
And ran it with time code
and got:
real 0m0.001s
user 0m0.000s
sys 0m0.001s
Running the loop for 10000000 times gave me:
real 0m0.045s
user 0m0.044s
sys 0m0.000s
I ran it with strace -c -ttT ./code
and got
% time seconds usecs/call calls errors syscall
-nan 0.000000 0 2 read
-nan 0.000000 0 3 open
-nan 0.000000 0 3 close
-nan 0.000000 0 3 fstat
-nan 0.000000 0 11 mmap
-nan 0.000000 0 5 mprotect
-nan 0.000000 0 1 munmap
-nan 0.000000 0 1 brk
-nan 0.000000 0 2 rt_sigaction
-nan 0.000000 0 1 rt_sigprocmask
-nan 0.000000 0 1 1 access
-nan 0.000000 0 1 execve
-nan 0.000000 0 1 getrlimit
-nan 0.000000 0 1 arch_prctl
-nan 0.000000 0 2 1 futex
-nan 0.000000 0 1 set_tid_address
-nan 0.000000 0 1 set_robust_list
100.00 0.000000 40 2 total