gettimeofday being faster than getpid?

Pavel Machek (pavel@bug.ucw.cz)
Tue, 2 Nov 1999 14:37:30 +0100


Hi!

I did some tests, and when I replace getuid() or getpid() with
gettimeofday(), it actually gets faster.

getuid takes 14usec on my machine.
gettimeofday takes 4usec on my machine.

I think that is pretty strange.
Pavel

#include <sys/time.h>
#include <unistd.h>

void main(void)
{
struct timeval tv1, tv2, tv3;

gettimeofday(&tv1, 0);
getuid(); <--- here
gettimeofday(&tv2, 0);

printf("Time1: %d:%d\n", tv1.tv_sec, tv1.tv_usec);
printf("Time2: %d:%d\n", tv2.tv_sec, tv2.tv_usec);
}

-- 
I'm really pavel@ucw.cz. Look at http://195.113.31.123/~pavel.  Pavel
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/