>This is particularly true when JIT compilation is
>involved.

Good point about the JIT.  I hadn't considered that.  You mentioned JIT
here.  I was comparing unmanaged C++ to managed C#.  That is, no /clr on
the C++ code.  You weren't using /clr in your test, right?

>knew - benchmarks don't necessarily tell us much.  :-)  I think we are
>doing more here to test the characteristics of the heap manager than
>anything else.

I think you are very right about mostly testing the heap manager.

Do you agree that reallocation doesn't always improve performance
significantly?

Certainly in this test (large array, constant value) it
does appear to be slower (not significantly, but a little).

    >By value, dynamically reallocated | >By value, preallocated
                                       | (with pause between test)
    >----Test 0                        | >----Test 0
    >Elapsed 640 ms                    | >Elapsed 661 ms
    >----Test 1                        | >----Test 1
    >Elapsed 590 ms                    | >Elapsed 651 ms
    >----Test 2                        | >----Test 2
    >Elapsed 691 ms                    | >Elapsed 651 ms
    >----Test 3                        | >----Test 3
    >Elapsed 621 ms                    | >Elapsed 651 ms
    >----Test 4                        | >----Test 4
    >Elapsed 601 ms                    | >Elapsed 651 ms
  ----------------------             ------------------------------
    average 629                          average 653

I found this important because the advice given to a recent poster,
concerning benchmarking, was to preallocated.  I would have agreed that
should improve performance by some noticeable factor (x2, x5).  But in
this case, at least, it makes no improvement all.  Once again proving that
you should test/profile and not theorize about actual performance.  :-)

David

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to