473,395 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.
Jun 13 '07 #1
7 2384
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.
Jun 13 '07 #2
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.
Jun 13 '07 #3
"desktop" <ff*@sss.comwrote in message
news:f4**********@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).
Jun 13 '07 #4
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
Jun 13 '07 #5
On 13 Jun, 10:25, "Jim Langston" <tazmas...@rocketmail.comwrote:
"desktop" <f...@sss.comwrote in message

news:f4**********@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>. <ctimeshould not give
you ::clock. If you include <time.hyou 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

Jun 13 '07 #6
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
Jun 13 '07 #7
On Jun 13, 11:25 am, "Jim Langston" <tazmas...@rocketmail.comwrote:
"desktop" <f...@sss.comwrote in message
news:f4**********@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.hand 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: ja*********@gmail.com
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
Jun 13 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Rob | last post by:
Good afternoon, I'm looking for information on good benchmarking implementations with which to test MySQL using multiple clients. The benchmark utilities included with MySQL are, as far as I...
1
by: Trevor Best | last post by:
Is there a ready made database for benchmarking a server's performance to see what tweaks external to SQL Server will have an effect? -- A)bort, R)etry, I)nfluence with large hammer.
8
by: Jerry Coffin | last post by:
As promised, more benchmarking results of comparing C++ to Java. This time around, our first target will be the strcat program. This is one that the C++ version rather bothered me -- I'm...
1
by: Carlo Razzeto | last post by:
Hey there, I have a question about benchmarking. I'm hoping you can help but I'm not sure if this group is dedicated to just standard C++. Here's the question, I have a piece of code I would like...
5
by: Tom Gurath | last post by:
http://osnews.com/story.php?news_id=5602&page=2 This benchmark tests the Math & File I/O of 9 languages/run-times. Visual C++ (Version 7 - not managed) Visual C# gcc C Visual Basic.NET Visual...
10
by: Michel Rouzic | last post by:
I need to determine how long does an addition take and how long does a multiplication takes. So far I've been trying to use the clock() function in my programs in order to find out how long it took...
7
by: Wisgary | last post by:
I'm doing some benchmarking tests to compare Microsoft's CLR against Mono's CLR. I could use some suggestions for how to objectively compare the code. To my surprise the few tests I've run so far...
2
by: chitranjan | last post by:
Hello All, I want to do Bechmarking of PostgreSQL on Linux (fedora) so,please tell me about benchmarking tools of postgresql which is easy to use and implement..It is very urgent for me to do...
0
by: crocodilu2008 | last post by:
JSON vs. XML JSON and XML are basically used for the same purpose—to represent and interchange data. I'll try to show you why you might want to use JSON rather than XML in an AJAX context by showing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.