lkml.org 
[lkml]   [1999]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: gettimeofday being faster than getpid?
On Tue, 2 Nov 1999, Pavel Machek wrote:

> 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);
> }

Just add one getuid() before the first gettimeofday() and the strangeness
takes another form. The difference disappears.
I'm afraid you are measuring your cache performance I guess.

Robert

--
Robert de Vries
rhdv@rhdv.cistron.nl


-
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/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:8.250 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site