Re: [Boost-users] Does shared_array's get()methodintroduceruntimeoverhead?

-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Peng Yu Sent: Tuesday, October 24, 2006 6:31 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] Does shared_array's get()methodintroduceruntimeoverhead?
On 10/24/06, Sohail Somani
wrote: -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Peng Yu Sent: Tuesday, October 24, 2006 5:33 PM Does it mean that code segment 1 is as fast as segment 2, but code segment 3 is the slowest?
///////1 boost::shared_array a(new int[100]); for(int i = 0; i < 100; ++ i) a.get()[i] = i;
////////2 boost::shared_array a(new int[100]); int a_ptr = a.get(); for(int i = 0; i < 100; ++ i) a_ptr[i] = i;
////////3 boost::shared_array a(new int[100]); for(int i = 0; i < 100; ++ i) a[i] = i;
All I can say is profile, profile, profile!
PS: Profile. PPS: I'd guesstimate with a proper C++ compiler + optimizer, you wouldn't notice much of a difference between 1 and 3.
Could you recommend a profiler on linux x86?
I recall using something called callgrind. There is a gui called kcachegrind. I hope that should give you enough search keywords. Its been a while since I profiled on linux. You also always have the gcc option -pg which I've used quite often.
participants (1)
-
Sohail Somani