473,394 Members | 1,641 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,394 software developers and data experts.

Another quest for speed

BBox::Expand(float delta){
Vector d = Vector(delta, delta, delta);
p_min -= d;
p_max += d;
}

BBox::Expand(float delta){
p_min -= Vector(delta, delta, delta);
p_max += Vector(delta, delta, delta);
}

Logically the first method would only make 1 Vector object and the
second 2, so method two would take more cpu instructions? Or does c++
do some intern stuff to optimise this?
Jan 28 '08 #1
1 1210
mi**************@gmail.com wrote:
BBox::Expand(float delta){
Vector d = Vector(delta, delta, delta);
p_min -= d;
p_max += d;
}

BBox::Expand(float delta){
p_min -= Vector(delta, delta, delta);
p_max += Vector(delta, delta, delta);
}

Logically the first method would only make 1 Vector object and the
second 2, so method two would take more cpu instructions? Or does c++
do some intern stuff to optimise this?
It's really easy to measure this sort of thing: write the code (looks
like you've already done it), add a simple main() that calls it a few
zillion times, compile with all available optimisations enabled, and
measure execution time. That will give you a more accurate answer for
your compiler and hardware than all the people here can offer, and it's
quicker.

FWIW, my guess is that as long as the caller can see Vector's
constructor and BBox::Expand and the rest inline, then you'll get
essentially optimal code from both.

If you're coding for an x86 system and performance is vital, then you
may like to investigate using SIMD instructions for this sort of thing,
i.e. processing the x, y and z components in parallel. How to do that
is off-topic for this group, but it's likely to make more impact than
tweaking the details of the C++ coding style.
Phil.
Jan 28 '08 #2

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

Similar topics

33
by: Quest Master | last post by:
I am interested in developing an application where the user has an ample amount of power to customize the application to their needs, and I feel this would best be accomplished if a scripting...
1
by: Trent | last post by:
Hello, I was wondering if anyone here could help with a Quest Central issue. I have two different hosts listed in Quest Central. Each host has a database on it, but the databases have the...
3
by: Robert Stearns | last post by:
Apparently due to an intellectual property suit by CA, Quest Central for DB2 has gone away. They can/will not sell any license extensions. In a project I am doing, we make extensive use of quest...
9
by: Tempy | last post by:
Good day all, i am a newbie to this game and would like to know if it is possible to open other DB's from the switchboard of another ? What i would like to do is have one icon on the desktop and...
4
by: bj7lewis | last post by:
I am currently C++/Win32/MFC & C# programmer using VS.NET 2002 and jumped into VS.NET 2003 but that was a waste so I skipped VS.NET 2005 cause buying VS.NET 2003. Now after checking out VS.NET 2008...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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
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,...
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...

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.