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 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.
On 10/24/06, Sohail Somani
-----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? Thanks, Peng
participants (2)
-
Peng Yu
-
Sohail Somani