Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Performance penalty for encapsulations ??
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Kevin Goodsell, post: 1457690"] There are a lot of possible contributors to the performance decrease. I don't know how you are measuring the time, but note that you are constructing 30000000 class instances, which is obviously going to take some time. Did you include that in your timing? Another likely issue is that you've reduced the compiler's ability to optimize. You can create pretty significant optimizations by using classes well, but if you use them poorly all you do is complicate the compiler's job, likely making the code less efficient. You don't need to say 'inline' here. Functions defined within the class definition are always inlined. If that was supposed to be a conversion to int you got it wrong. operator int() { return i; } Why macros? Macros are bad. Use typedef and const instead. I don't think this is a legal signature for main. According to the standard, the second argument must be 'char *argv[]' or something equivalent. I don't think adding 'const' is allowed. What's with the extra redundant blocks? [i][i][i][i] -Kevin[/i][/i][/i][/i] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Performance penalty for encapsulations ??
Top