cassius
May 26th, 2008, 06:53 PM
I am in the process of rewriting a simulation application and I need to look at all my options for accelerating the execution. I've never had to concern myself this much with performance So I have a few (3) questions. I have separated the questions below. Thank you in advance for your replies.
====QUESTION 1======
If you completely disregard the benefits of OOD/OOP in terms of maintenance and reusability, can faster performance be achieved through a procedural approach using structs to organize the data? For instance, my simulator needs to do a lot of simple data comparisons so would there be a significant performance difference between the following two approaches:
Approach 1
if (record1.testValue > record2.testValue){...}
Approach 2
if (obj1.getTestValue() > obj2.getTestValue()){...}
====QUESTION 2======
I almost hate to ask this, but is there any performance boost associated with using globals instead of passing by reference? I know it's ugly to use globals, but I would consider it if there was a return on performance
====QUESTION 3======
which of these would be most efficient under an OOP paradigm? It seems like it should be approach 1, but perhaps I'm wrong.
Approach 1
int localTestValue;
localTestValue = ((obj1.returnNewValue() - 2) % 3)
if (localTestValue == 2){...}
Approach 2
int localTestValue;
localTestValue = obj1.returnNewValue();
if ((localTestValue == 2) || (localTestValue == 5) || (localTestValue == 8)){...}
Approach 3
if ((obj1.returnNewValue() == 2) || (obj1.returnNewValue() == 5) || (obj1.returnNewValue() == 8)){...}
Thanks again.
====QUESTION 1======
If you completely disregard the benefits of OOD/OOP in terms of maintenance and reusability, can faster performance be achieved through a procedural approach using structs to organize the data? For instance, my simulator needs to do a lot of simple data comparisons so would there be a significant performance difference between the following two approaches:
Approach 1
if (record1.testValue > record2.testValue){...}
Approach 2
if (obj1.getTestValue() > obj2.getTestValue()){...}
====QUESTION 2======
I almost hate to ask this, but is there any performance boost associated with using globals instead of passing by reference? I know it's ugly to use globals, but I would consider it if there was a return on performance
====QUESTION 3======
which of these would be most efficient under an OOP paradigm? It seems like it should be approach 1, but perhaps I'm wrong.
Approach 1
int localTestValue;
localTestValue = ((obj1.returnNewValue() - 2) % 3)
if (localTestValue == 2){...}
Approach 2
int localTestValue;
localTestValue = obj1.returnNewValue();
if ((localTestValue == 2) || (localTestValue == 5) || (localTestValue == 8)){...}
Approach 3
if ((obj1.returnNewValue() == 2) || (obj1.returnNewValue() == 5) || (obj1.returnNewValue() == 8)){...}
Thanks again.