473,498 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: performance measure for optimized c++ code

On 9 jul, 15:16, "gautamcoo...@gmail.com" <gautamcoo...@gmail.com>
wrote:
I want to measure the execution time of a function, which is in the
[...]
I have some doubts about this approach -
With full compiler optimizations, I am not sure if the compiler is
making use of the facts that
[...]
So the compiler might be executing the function partially or in a
different manner. I do not want that, as it will obviously give a
misleading results.
The compiler does not "execute" nothing. But I understand what you
mean. The compiler only optimizes what it can see at compile time,
nothing more, nothing less. You can separate your target function and
the loop in two distinct modules, so you will be pretty sure the
compiler will not fold the loop.

Cheers,
Dijkstra.
Jul 9 '08 #1
1 1487
On Jul 10, 1:23 am, Dijkstra <pepi...@gmail.comwrote:
On 9 jul, 15:16, "gautamcoo...@gmail.com" <gautamcoo...@gmail.com>
wrote:
I want to measure the execution time of a function, which is in the
[...]
I have some doubts about this approach -
With full compiler optimizations, I am not sure if the compiler is
making use of the facts that
[...]
So the compiler might be executing the function partially or in a
different manner. I do not want that, as it will obviously give a
misleading results.
The compiler does not "execute" nothing. But I understand what you
mean. The compiler only optimizes what it can see at compile time,
nothing more, nothing less. You can separate your target function and
the loop in two distinct modules, so you will be pretty sure the
compiler will not fold the loop.
Unless you're using Sun CC. Or VC++. Or any one of a number of
other compilers which can optimize across translation
boundaries. (Of course, you usually need special options for
such optimization.)

My own solution has been to make the function virtual, which
seems to suffice for the compilers I currently use (but I have
no guarantees for the future). And I do ensure that the
function "does something" which affects global state. And that
the same call point uses different types of objects (and thus
resolves to a different function) at different times in the
execution. (Amongst other things, I make a dry run, with an
empty virtual function, to establish a base value, which is then
subtracted from all of the other run times.)

The only way to be sure, of course, is to look at the code the
compiler is generating, and determine manually if the
optimizations it is doing are falsifying the measurement. And
to be cleverer than the authors of the compiler.

--
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
Jul 10 '08 #2

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

Similar topics

0
1402
by: Jeff Davis | last post by:
I was doing some thinking about exponentiation algorithms along with a friend, and I happened upon some interesting results. Particularly, I was able to outperform the ** operator in at least one...
133
8423
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
3
2136
by: Alex Vinokur | last post by:
For instance, we need to measure performance of assignment 'ch1 = ch2' where ch1 and ch2 are of char type. We need to do that for different optimization levels of the same compiler. Here is...
23
3455
by: Rudolf Bargholz | last post by:
Hi, I have a ralatively simple SQL: select FK from TABLE where upper(A) like 'B%' and upper(C) like 'D%' We have DB2 UDB v7.1 FP 12 installed on Linux and on Windows 2003 On Linux using...
4
3350
by: Martin | last post by:
I am using graphics as backgrounds for forms,buttons,labels etc. The question is: is it faster to load all graphics from files on app start or to use it embeded (places in editor during design)....
20
2080
by: John Mark Howell | last post by:
I had a customer call about some C# code they had put together that was handling some large arrays. The performance was rather poor. The C# code runs in about 22 seconds and the equivalent...
8
1530
by: Gary Wessle | last post by:
Hi while I am reading this C++ book, I noticed the iterator is being used to loop through a container, say a vector. I am used to use "for(int=0;i<vec.size();++i)" which is better to use? ...
13
4575
by: atlaste | last post by:
Hi, I'm currently developing an application that uses a lot of computational power, disk access and memory caching (to be more exact: an information retrieval platform). In these kind of...
30
3470
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
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,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.