Boost logo

Boost Users :

From: Sohail Somani (s.somani_at_[hidden])
Date: 2006-10-24 21:35:18


> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Peng Yu
> Sent: Tuesday, October 24, 2006 6:31 PM
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] Does shared_array's
> get()methodintroduceruntimeoverhead?
>
> On 10/24/06, Sohail Somani <s.somani_at_[hidden]> wrote:
> > > -----Original Message-----
> > > From: boost-users-bounces_at_[hidden]
> > > [mailto:boost-users-bounces_at_[hidden]] 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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net