Utility to report performance characteristics of standard C/C++library implementation?

Discussion in 'C++' started by Boris Du¹ek, Jun 15, 2009.

  1. Boris Du¹ek

    Boris Du¹ek Guest

    Hello,

    I would like to get more insight into how much some common operations
    in C/C++ standard library cost in terms of performance, and also how
    these costs differ between different platforms (like vc9 vs. vc10 beta
    1 vs. g++-4.1.2/Linux-32 vs. g++-4.0.1/OS X). I started to write a
    small utility for that with stuff I am currently interested in (like
    cost of malloc/free, cost of "string str; copy(data, data + n,
    back_inserter(str)" versus cost of "string str(data, data + n)",
    similar with transform versus boost::transform_iterator). Also I
    output allocation strategy for vector and string (and learn libstdc++
    is strictly exponential with base of 2, while Microsoft's string
    implementation has minimal storage allocated and then behaves
    ~exponentially, but not with base of 2.

    But I think I am probably reinventing the wheel. Isn't there a utility
    that is portable and assesses such characteristics and outputs them
    for study by an interested developer (possibly calibrating the results
    w.r.t. CPU power/load)? I also guess such utility would be great for
    developers of standard libraries, since they can both catch
    performance regressions and compare with competition, so I hope there
    is something available.

    Thanks for any pointers,
    Boris Dušek
    Boris Du¹ek, Jun 15, 2009
    #1
    1. Advertising

  2. Boris Du¹ek

    Jorgen Grahn Guest

    Re: Utility to report performance characteristics of standard C/C++ library implementation?

    On Mon, 15 Jun 2009 04:36:03 -0700 (PDT), Boris Du¹ek <> wrote:
    > Hello,
    >
    > I would like to get more insight into how much some common operations
    > in C/C++ standard library cost in terms of performance, and also how
    > these costs differ between different platforms (like vc9 vs. vc10 beta
    > 1 vs. g++-4.1.2/Linux-32 vs. g++-4.0.1/OS X). I started to write a
    > small utility for that with stuff I am currently interested in (like
    > cost of malloc/free, cost of "string str; copy(data, data + n,
    > back_inserter(str)" versus cost of "string str(data, data + n)",
    > similar with transform versus boost::transform_iterator). Also I
    > output allocation strategy for vector and string (and learn libstdc++
    > is strictly exponential with base of 2, while Microsoft's string
    > implementation has minimal storage allocated and then behaves
    > ~exponentially, but not with base of 2.
    >
    > But I think I am probably reinventing the wheel. Isn't there a utility
    > that is portable and assesses such characteristics and outputs them
    > for study by an interested developer


    There is. Under Unix, I use my shell's 'time' command, and a profiler
    (gprof). That's what people here mean when they say "don't guess,
    measure" when discussing optimization.

    > (possibly calibrating the results
    > w.r.t. CPU power/load)?


    Probably not worth trying. There are too many factors involved (cache
    characteristics, for example).

    > I also guess such utility would be great for
    > developers of standard libraries, since they can both catch
    > performance regressions and compare with competition, so I hope there
    > is something available.


    They should be interested in performance yes, but they are a tiny,
    tiny minority of all C++ users. It's mostly ordinaty users like you
    and me who should use such tools, and when we hit a bottleneck it is
    almost never a fixable bottleneck in the standard library but our own
    fault.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
    \X/ snipabacken.se> R'lyeh wgah'nagl fhtagn!
    Jorgen Grahn, Jun 16, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gb
    Replies:
    1
    Views:
    327
    Steve C. Orr, MCSD
    Aug 22, 2003
  2. Aaron

    disable asp.net characteristics

    Aaron, Mar 7, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    421
    bruce barker
    Mar 7, 2005
  3. indra
    Replies:
    1
    Views:
    456
    Juan T. Llibre
    Aug 29, 2005
  4. Gary N.
    Replies:
    2
    Views:
    4,095
    Chris Smith
    Jan 9, 2004
  5. Peter Olcott
    Replies:
    36
    Views:
    3,162
    Jonathan N. Little
    Jun 20, 2006
Loading...

Share This Page