Unexpected performance results

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    Unexpected performance results

    Hello all,

    Can anybody think of a plausible explanation for why my profiler is telling
    me that I get better performance with map::operator[] than with
    map::insert()?

    Thanks,
    Dave


  • Leor Zolman

    #2
    Re: Unexpected performance results

    On Thu, 8 Apr 2004 11:24:24 -0700, "Dave" <better_cs_now@ yahoo.com> wrote:
    [color=blue]
    >Hello all,
    >
    >Can anybody think of a plausible explanation for why my profiler is telling
    >me that I get better performance with map::operator[] than with
    >map::insert( )?[/color]

    This would be totally a QOI issue, but I did take a look just for grins in
    an implementation or two, and I noticed that, even though operator[] tends
    to call insert() to do its work, insert() returns a pair<...> by value
    while operator[] just returns a ref to an element. Perhaps the construction
    of that return value from insert() might be your culprit...
    -leor[color=blue]
    >
    >Thanks,
    >Dave
    >[/color]

    --
    Leor Zolman --- BD Software --- www.bdsoft.com
    On-Site Training in C/C++, Java, Perl and Unix
    C++ users: Download BD Software's free STL Error Message Decryptor at:
    An STL Error Decryptor for C++ by Leor Zolman of BD Software - available to download here

    Comment

    • Leor Zolman

      #3
      Re: Unexpected performance results

      On Thu, 8 Apr 2004 11:24:24 -0700, "Dave" <better_cs_now@ yahoo.com> wrote:
      [color=blue]
      >Hello all,
      >
      >Can anybody think of a plausible explanation for why my profiler is telling
      >me that I get better performance with map::operator[] than with
      >map::insert( )?[/color]

      This would be totally a QOI issue, but I did take a look just for grins in
      an implementation or two, and I noticed that, even though operator[] tends
      to call insert() to do its work, insert() returns a pair<...> by value
      while operator[] just returns a ref to an element. Perhaps the construction
      of that return value from insert() might be your culprit...
      -leor[color=blue]
      >
      >Thanks,
      >Dave
      >[/color]

      --
      Leor Zolman --- BD Software --- www.bdsoft.com
      On-Site Training in C/C++, Java, Perl and Unix
      C++ users: Download BD Software's free STL Error Message Decryptor at:
      An STL Error Decryptor for C++ by Leor Zolman of BD Software - available to download here

      Comment

      Working...