All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akos Marton <makos999@gmail.com>
To: Michal Nazarewicz <mina86@mina86.com>
Cc: linux-c-programming <linux-c-programming@vger.kernel.org>
Subject: Re: time system call expensive?
Date: Thu, 21 Jul 2011 13:46:17 +0200	[thread overview]
Message-ID: <4E281189.8010904@gmail.com> (raw)
In-Reply-To: <op.vyyu34nf3l0zgt@mnazarewicz-glaptop>

[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]

I advice you `man 3 clock`.
If you want to get much more precision the attached project can help you.
Does it help?

Regards,
mAkos


Michal Nazarewicz wrote:
> On Thu, 21 Jul 2011 06:41:14 +0200, Vadiraj <vadiraj.cs@gmail.com> wrote:
>> I'm evaluating time consumed by method. I'm using time(NULL) system
>> call to capture time before and after the call to the function.
>> Just wanted to know if this has a considerable performance hit? For
>> all I believe time syscall is quite optimized and should not really be
>> matter of concern.
>>
>> Please let me know if someone have evaluated time(NULL) system over head..
>>
>> Assuming the method I'm evaluating is a frequently called method.
> 
> Why do you worry about it?  What do you need the time for?  If are
> really using time(2) it means that the function you're calling run time
> is counted in seconds.  If that's the case, two call to time(2) are
> by all means negligible.
> 
> If you need in for benchmark, you would probably do something like:
> 
> start = time(NULL)
> for (vary big number)
>     call function you benchmark
> end = time(NULL)
> 
> In either case, you should check gettimeofday(2).
> 


[-- Attachment #2: timing.tar.bz2 --]
[-- Type: application/octet-stream, Size: 1150 bytes --]

  reply	other threads:[~2011-07-21 11:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-21  4:41 time system call expensive? Vadiraj
2011-07-21 11:20 ` Michal Nazarewicz
2011-07-21 11:46   ` Akos Marton [this message]
2011-07-22  4:57     ` Vadiraj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E281189.8010904@gmail.com \
    --to=makos999@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=mina86@mina86.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.