Objectmix
Tags Register Mark Forums Read

Benchmarking program to test C++ functions? : c++

This is a discussion on Benchmarking program to test C++ functions? within the c++ forums in Programming Languages category; I have written two different insert functions in a C++ program and would like to test the difference in performance. Can you recommend any benchmarking software for C++ functions that can do this job? I am working under linux/ubuntu....


Object Mix > Programming Languages > c++ > Benchmarking program to test C++ functions?

c++ comp.lang.c++ usenet archive

Reply

 

LinkBack Thread Tools
  #1  
Old 06-13-2007, 04:09 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Benchmarking program to test C++ functions?

I have written two different insert functions in a C++ program and would
like to test the difference in performance.

Can you recommend any benchmarking software for C++ functions that can
do this job? I am working under linux/ubuntu.
Reply With Quote
  #2  
Old 06-13-2007, 04:14 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Benchmarking program to test C++ functions?

desktop wrote:
> I have written two different insert functions in a C++ program and would
> like to test the difference in performance.
>
> Can you recommend any benchmarking software for C++ functions that can
> do this job? I am working under linux/ubuntu.


time(1)?

--
Ian Collins.
Reply With Quote
  #3  
Old 06-13-2007, 04:23 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Benchmarking program to test C++ functions?

Ian Collins wrote:
> desktop wrote:
>> I have written two different insert functions in a C++ program and would
>> like to test the difference in performance.
>>
>> Can you recommend any benchmarking software for C++ functions that can
>> do this job? I am working under linux/ubuntu.

>
> time(1)?
>


I was thinking something with a GUI interface and the option to do plots.
Reply With Quote
  #4  
Old 06-13-2007, 04:25 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Benchmarking program to test C++ functions?

"desktop" <fff@sss.com> wrote in message
news:f4oc7h$952$1@news.net.uni-c.dk...
>I have written two different insert functions in a C++ program and would
>like to test the difference in performance.
>
> Can you recommend any benchmarking software for C++ functions that can do
> this job? I am working under linux/ubuntu.


I just use clock. such as:

clock_t Start = clock();
// Map find is so fast one search reports 0ns
for ( int i = 0; i < 1000; ++i )
FindInMap( "Bogus", "Bogus", MapData );
clock_t End = clock();
std::cout << "Search for non existant entry in Map: " <<
static_cast<double>( End - Start ) / 1000.0 << "ns\n";

You would need to include <ctime>

I am not sure if it's supposed to be std::clock or not (not using namespace
std, yet it finds it anyway in windows).


Reply With Quote
  #5  
Old 06-13-2007, 05:17 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Benchmarking program to test C++ functions?

desktop wrote:

> Can you recommend any benchmarking software for C++ functions that can
> do this job? I am working under linux/ubuntu.


Take a look at cachegrind and it's KDE frontend kcachegrind. It uses
valgrind and it's readily available from the Ubuntu repositories.


Hope this helps
Rui Maciel
Reply With Quote
  #6  
Old 06-13-2007, 08:36 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Benchmarking program to test C++ functions?

On 13 Jun, 10:25, "Jim Langston" <tazmas...@rocketmail.com> wrote:
> "desktop" <f...@sss.com> wrote in message
>
> news:f4oc7h$952$1@news.net.uni-c.dk...
>
> >I have written two different insert functions in a C++ program and would
> >like to test the difference in performance.

>
> > Can you recommend any benchmarking software for C++ functions that can do
> > this job? I am working under linux/ubuntu.

>
> I just use clock. such as:
>
> clock_t Start = clock();
> // Map find is so fast one search reports 0ns
> for ( int i = 0; i < 1000; ++i )
> FindInMap( "Bogus", "Bogus", MapData );
> clock_t End = clock();
> std::cout << "Search for non existant entry in Map: " <<
> static_cast<double>( End - Start ) / 1000.0 << "ns\n";
>
> You would need to include <ctime>
>
> I am not sure if it's supposed to be std::clock or not


Yes it is, if you get it by including <ctime>. <ctime> should not give
you ::clock. If you include <time.h> you are supposed to get ::clock
and std::clock.

> (not using namespace
> std, yet it finds it anyway in windows).


Doesn't surprise me. A lot of popular implementations seem to get this
wrong and so formally incorrect code like yours above successfully
compiles.

I've found the problem widespread enough to not bother with <cxxx>
headers. YMMV.

Gavin Deane

Reply With Quote
  #7  
Old 06-13-2007, 08:40 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Benchmarking program to test C++ functions?

desktop wrote:
> Ian Collins wrote:
>> desktop wrote:
>>> I have written two different insert functions in a C++ program and would
>>> like to test the difference in performance.
>>>
>>> Can you recommend any benchmarking software for C++ functions that can
>>> do this job? I am working under linux/ubuntu.

>>
>> time(1)?
>>

>
> I was thinking something with a GUI interface and the option to do plots.


I don't know which plots may you be interested in, but you are probably
looking for a profiler. Check out gprof and kprof.

Regards,

Zeppe
Reply With Quote
  #8  
Old 06-13-2007, 01:49 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Benchmarking program to test C++ functions?

On Jun 13, 11:25 am, "Jim Langston" <tazmas...@rocketmail.com> wrote:
> "desktop" <f...@sss.com> wrote in message


> news:f4oc7h$952$1@news.net.uni-c.dk...


> >I have written two different insert functions in a C++ program and would
> >like to test the difference in performance.


> > Can you recommend any benchmarking software for C++ functions that can do
> > this job? I am working under linux/ubuntu.


> I just use clock. such as:


> clock_t Start = clock();
> // Map find is so fast one search reports 0ns
> for ( int i = 0; i < 1000; ++i )
> FindInMap( "Bogus", "Bogus", MapData );
> clock_t End = clock();
> std::cout << "Search for non existant entry in Map: " <<
> static_cast<double>( End - Start ) / 1000.0 << "ns\n";


> You would need to include <ctime>


> I am not sure if it's supposed to be std::clock or not (not
> using namespace std, yet it finds it anyway in windows).


If you include <ctime>, it's suppose to be std::clock, and only
std::clock. If you include <time.h>, it's suppose to be both
std::clock and ::clock. To date, I've yet to see a conforming
implementation; I include <time.h> and use clock (no :, and
that seems to work everywhere.

The problem with this solution, per se, is that you really need
something to ensure that the optimizer doesn't eliminate the
find completely. What I've used, to date, is to put the
fonction to be tested in a virtual function in a derived class,
and to ensure that it uses the results of what I'm testing to
update something in the object. This seems to have worked so
far, but one day or other, I'm sure that compilers will make it
insufficient as well.

If anyone's interested, the code is in BenchHarness, in the Test
subsystem at my site (http://kanze.james.neuf.fr/code-en.html,
when it's working).

--
James Kanze (Gabi Software) email: james.kanze@
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


Reply With Quote
Reply

Thread Tools


Similar Threads

Thread Thread Starter Forum Replies Last Post
Erros when compiling a CPP program which uses CPython API functions usenet Python 6 12-07-2007 06:05 AM
print all the functions invoked in a C program usenet c++ 7 10-31-2007 04:52 PM
Timer functions for DOS box program? usenet C 2 09-07-2007 12:15 AM
Help structuring my program (arrays of function pointers/ passing variables to functions) usenet C 3 07-20-2007 08:25 AM
ifort functions for test NaN and Inf usenet Fortran 10 07-19-2007 10:21 AM


All times are GMT -5. The time now is 10:04 AM.