[ Home ] Passports | National Anthems in MP3 | Live chat

Live chat

News | Forum
 

Train Museum:

Warsaw, PolandSeoul, KoreaKyoto, Japan Forums: Rail UK, Rail Australia
Pictures: MoneyMonorailHong Kong light festival High speed trainQueen Elizabeth II in YokohamaTaro - Galapagos Tortoise



Subject: Re: faster gettimeofday? Posted on: Mon, 08 Mar 2010 16:44:33 +1300

Sumer Cip wrote:
> Hi all,
>
> I am developing a profiler, and in my tests, it seems most of time
> spent in the profiler is the gettimeofday() function. I have also used
> clock_gettime() function and gives same results. Is there any way to
> optimize the below piece of code more? Maybe another syscall I am
> missing or anything?
>
> static long long
> tickcount(void)
> {
> struct timeval tv;
> long long rc;
> #ifdef GETTIMEOFDAY_NO_TZ
> gettimeofday(&tv);
> #else
> gettimeofday(&tv, (struct timezone *)NULL);
> #endif
> rc = tv.tv_sec;
> rc = rc * 1000000 + tv.tv_usec;
> return rc;
> }

It should be fast. On Solaris, gettimeofday() is a fairly thin wrapper
for gethrtime(). So if your system supports it (I think it is a POSIX
RT function), use that.

--
Ian Collins

200869. Re: Stylistic questions on UNIX C coding. 200869
200870. Re: Stylistic questions on UNIX C coding. 200870
200871. Re: Stylistic questions on UNIX C coding. 200871
200872. 7 x = ."It's" IF ." " ELSE ."not " THEN ."equal" 200872
200873. if (2 == company && 3 == crowd) ... 200873
200874. Re: Stylistic questions on UNIX C coding. 200874
200875. Re: Impact of solid-state drives 200875
200876. Re: Impact of solid-state drives 200876
200877. Re: Impact of solid-state drives 200877
200878. Re: if (2 == company && 3 == crowd) ... 200878
200879. Re: if (2 == company && 3 == crowd) ... 200879
200880. Re: if (2 == company && 3 == crowd) ... 200880
200881. Re: Stylistic questions on UNIX C coding. 200881
200882. Reg /proc/stat 200882
200883. Re: Stylistic questions on UNIX C coding. 200883
200884. Re: if (2 == company && 3 == crowd) ... 200884
200885. Re: Stylistic questions on UNIX C coding. 200885
200886. Re: Impact of solid-state drives 200886
200887. Re: if (2 == company && 3 == crowd) ... 200887
200888. Re: Stylistic questions on UNIX C coding. 200888