Re: OT: recommended way of timing two pieces of code in C

2016-02-29 Thread Rick Stevens
On 02/27/2016 06:48 AM, Ranjan Maitra wrote: On Sat, 27 Feb 2016 14:09:25 + "Patrick O'Callaghan" wrote: On Sat, 2016-02-27 at 07:44 -0600, Ranjan Maitra wrote: #define INTERVAL 1/* number of milliseconds to go off */ int main() { double sum = 0;

Re: OT: recommended way of timing two pieces of code in C

2016-02-27 Thread Ranjan Maitra
On Sat, 27 Feb 2016 14:09:25 + "Patrick O'Callaghan" wrote: > On Sat, 2016-02-27 at 07:44 -0600, Ranjan Maitra wrote: > > #define INTERVAL 1    /* number of milliseconds to go off */ > > > > int main() { > >     double sum = 0; > >     struct itimerval initial,

Re: OT: recommended way of timing two pieces of code in C

2016-02-27 Thread Patrick O'Callaghan
On Sat, 2016-02-27 at 07:44 -0600, Ranjan Maitra wrote: > #define INTERVAL 1    /* number of milliseconds to go off */ > > int main() { >     double sum = 0; >     struct itimerval initial, updated; > >     initial.it_value.tv_sec = INTERVAL/100; >     initial.it_value.tv_usec    =

Re: OT: recommended way of timing two pieces of code in C

2016-02-27 Thread Ranjan Maitra
> >>> > >> Note that the accuracy of this depends on several factors, such as how > >> long the measured interval is compared to the basic unit of timekeeping > >> (IOW if you want to measure the execution time of a short sequence of > >> instructions, you need to loop a few million times and

Re: OT: recommended way of timing two pieces of code in C

2016-02-27 Thread Tom Horsley
On Sat, 27 Feb 2016 11:39:11 + Patrick O'Callaghan wrote: > I doubt that will make any difference. As you said, the timers are > measuring process virtual time, so whether the process is scheduled > more or less frequently shouldn't matter. You'd be less confident if you'd seen the number of

Re: OT: recommended way of timing two pieces of code in C

2016-02-27 Thread Patrick O'Callaghan
On Fri, 2016-02-26 at 18:02 -0700, jd1008 wrote: > > Note that the accuracy of this depends on several factors, such as > how > > long the measured interval is compared to the basic unit of > timekeeping > > (IOW if you want to measure the execution time of a short sequence > of > > instructions,

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread John Morris
On Fri, 2016-02-26 at 12:06 -0600, Ranjan Maitra wrote: > Thank you! So, is there any way that these other processes can be > separated out in the time calculations? I can not come up with > definitive statements unless I can do these comparisons in a fair > manner. Not really. The days of

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread jd1008
On 02/26/2016 06:00 PM, Ranjan Maitra wrote: Indeed, I wanted to measure the total execution time of the algorithms (i.e. difference in CPU time after and before the function executing the algorithm is called) and independent of extraneous issues such as what other process is running at some

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread jd1008
On 02/26/2016 05:41 PM, Patrick O'Callaghan wrote: On Fri, 2016-02-26 at 17:31 -0700, jd1008 wrote: On 02/26/2016 05:28 PM, Ranjan Maitra wrote: Thanks again! OK, is there a way to calculate the FLOP instructions in C? What do you mean "calculate the FLOP instructions"? Are you trying to

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Ranjan Maitra
> > > Indeed, I wanted to measure the total execution time of the > > > algorithms (i.e. difference in CPU time after and before the > > > function executing the algorithm is called) and independent of > > > extraneous issues such as what other process is running at some > > > time, etc. I wanted

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Patrick O'Callaghan
On Fri, 2016-02-26 at 17:31 -0700, jd1008 wrote: > > On 02/26/2016 05:28 PM, Ranjan Maitra wrote: > > > > Thanks again! > > > > > > > > > > > > > OK, is there a way to calculate the FLOP instructions in C? > > > What do you mean "calculate the FLOP instructions"? Are you > > > trying to > > >

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Ranjan Maitra
> >> > >> __ > > Hi Ranjan, > > you have to use virtual timers instead of hard clock timers. > > > > Usually since you just want process time, then you start the itimer > > at the very start of the process, and give it some very long time to > > expire (say as long as max time). The just before

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread jd1008
On 02/26/2016 05:28 PM, Ranjan Maitra wrote: Thanks again! OK, is there a way to calculate the FLOP instructions in C? What do you mean "calculate the FLOP instructions"? Are you trying to evaluate an algorithm or benchmark an implementation? These are two different things. You can compare

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Ranjan Maitra
Thanks again! > > OK, is there a way to calculate the FLOP instructions in C? > > What do you mean "calculate the FLOP instructions"? Are you trying to > evaluate an algorithm or benchmark an implementation? These are two > different things. You can compare algorithms theoretically or by >

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Patrick O'Callaghan
On Fri, 2016-02-26 at 12:40 -0600, Ranjan Maitra wrote: > > I don't claim to be an expert but at first glance I wonder if > you've > > defined what you mean by efficiency. Execution time? Program size? > > Memory locality (affects virtual memory performance) etc. > > I responded to this on

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Jon LaBadie
On Fri, Feb 26, 2016 at 08:31:07AM -0600, Ranjan Maitra wrote: > Hi, > > Disclaimer: This is clearly marked OT, with the only connection to this group > being the fact that I am running F23 on a 20-core Dell T5810 @3.1 GHz each > and 64 GiB memory. My OT queries over the past 13 years (almost)

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread jd1008
On 02/26/2016 11:28 AM, jd1008 wrote: On 02/26/2016 11:06 AM, Ranjan Maitra wrote: On Fri, 26 Feb 2016 12:44:10 -0500 Tom Horsley wrote: On Fri, 26 Feb 2016 09:51:24 -0600 Ranjan Maitra wrote: How does this happen? The number of operations are exactly the same

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Ranjan Maitra
On Fri, 26 Feb 2016 17:29:58 + "Patrick O'Callaghan" wrote: > On Fri, 2016-02-26 at 08:31 -0600, Ranjan Maitra wrote: > > Hi, > > > > Disclaimer: This is clearly marked OT, with the only connection to > > this group being the fact that I am running F23 on a 20-core

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread jd1008
On 02/26/2016 11:06 AM, Ranjan Maitra wrote: On Fri, 26 Feb 2016 12:44:10 -0500 Tom Horsley wrote: On Fri, 26 Feb 2016 09:51:24 -0600 Ranjan Maitra wrote: How does this happen? The number of operations are exactly the same (or should be). The number of operations

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Ranjan Maitra
On Fri, 26 Feb 2016 11:02:41 -0700 jd1008 wrote: > > > On 02/26/2016 10:44 AM, Tom Horsley wrote: > > On Fri, 26 Feb 2016 09:51:24 -0600 > > Ranjan Maitra wrote: > > > >> How does this happen? The number of operations are exactly the same (or > >> should be). > > The number

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Ranjan Maitra
On Fri, 26 Feb 2016 12:44:10 -0500 Tom Horsley wrote: > On Fri, 26 Feb 2016 09:51:24 -0600 > Ranjan Maitra wrote: > > > How does this happen? The number of operations are exactly the same (or > > should be). > > The number of operations in your program are the same, but

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread jd1008
On 02/26/2016 10:44 AM, Tom Horsley wrote: On Fri, 26 Feb 2016 09:51:24 -0600 Ranjan Maitra wrote: How does this happen? The number of operations are exactly the same (or should be). The number of operations in your program are the same, but your program is running on the same machine as

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Tom Horsley
On Fri, 26 Feb 2016 09:51:24 -0600 Ranjan Maitra wrote: > How does this happen? The number of operations are exactly the same (or > should be). The number of operations in your program are the same, but your program is running on the same machine as the linux OS which has deamons running in the

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Patrick O'Callaghan
On Fri, 2016-02-26 at 08:31 -0600, Ranjan Maitra wrote: > Hi, > > Disclaimer: This is clearly marked OT, with the only connection to > this group being the fact that I am running F23 on a 20-core Dell > T5810 @3.1 GHz each and 64 GiB memory. My OT queries over the past 13 > years (almost) here

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Ranjan Maitra
Thanks! On Fri, 26 Feb 2016 10:16:18 -0500 Tom Horsley wrote: > On Fri, 26 Feb 2016 08:31:07 -0600 > Ranjan Maitra wrote: > > > I have been using get_rusage but I was wondering whether there is a better > > way? > > You most accurate wall time is going to come from

Re: OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Tom Horsley
On Fri, 26 Feb 2016 08:31:07 -0600 Ranjan Maitra wrote: > I have been using get_rusage but I was wondering whether there is a better > way? You most accurate wall time is going to come from looking at the TSC register (if you are on an x86 processor)

OT: recommended way of timing two pieces of code in C

2016-02-26 Thread Ranjan Maitra
Hi, Disclaimer: This is clearly marked OT, with the only connection to this group being the fact that I am running F23 on a 20-core Dell T5810 @3.1 GHz each and 64 GiB memory. My OT queries over the past 13 years (almost) here have elicited great wealth of information so I am posing here. So,