"private:" data members SLOOOW

Started by
21 comments, last by BSXrider 22 years, 2 months ago
quote:Original post by Stoffel
PS: if your test is this simple, I would highly suggest not doing a timed trial at all. Write a program that calls each function to be examined and then look at the disassembly--that way you know exactly what you''re talking about. I won''t go through the pain and suffering of doing it (I already know how to--you should learn), but I guarantee that these methods all compile to the same code.


quote:Original post by BSXrider
The assembler of all the options I listed better had NOT be the same - if it is then there''s a lot of wasted complexity in c++ !


quote:Original post by Stoffel
hope you''ll listen to me in the future


We have a bit of a comms tangle here. I did listen to your post, too closely in fact. It seemed to me that you said "these methods all compile to the same code". If you''d said "both" instead of "all" I might have seen your point, but instead I inferred that you meant ALL 5 of the options I''d listed. You see. My apologies

I agree with you on that disassembly though. Which is pretty much what options (4) and (5) in my original post determined, that the results were close enough the same. Because putting the function body in the class like you''ve done makes it automatically inlined.

quote:Original post by Kylotan
Did you conduct the tests in every possible order to avoid any order effects?


I knew someone would ask that but couldn''t think of a concise way of wording it in my post. Yes, I repeated them in differing orders (ctrl-z and ctrl-y were well used )

- seb
Advertisement
quote:Original post by BSXrider
MKH: A have the pro versio, yes. And yes this is a release compile. 1/2 a second? I'd be very impressed. Try it on yours and see what you get.

If you remove the grossly inefficent accessors, the optimizing version of MSVC will eliminate that loop.
As such, it takes 0.000000000 seconds on my computer.
One other thing (that I missed earlier) that loop isn't just coping numbers around - it's performing a full-blown ANSI/IEEE interger to floating point conversion - an Expen$ive operation.

IFF you insist on using an accessor, you need to return a non-const&.

        class Vect{public:float& x(){return v.x;}}        


[edit: I need to learn how to type]

Edited by - Magmai Kai Holmlor on January 30, 2002 8:33:42 PM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
quote:Original post by Stoffel
hmm, maybe it''s a course in scientist school, "How To Ignore your Engineers").




I believe thats a Marketing / Management class.


If the wind blows hard enough, even turkeys can fly

This topic is closed to new replies.

Advertisement