Re: C++ is slow
From: Andrey Tarasevich (andreytarasevich_at_hotmail.com)
Date: 03/06/04
- Next message: Josh Lessard: "Initializing unions"
- Previous message: Alf P. Steinbach: "Re: C++ is slow"
- In reply to: Julie: "Re: C++ is slow"
- Next in thread: Julie: "Re: C++ is slow"
- Reply: Julie: "Re: C++ is slow"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 05 Mar 2004 17:47:16 -0800
Julie wrote:
> ...
> I think that Leor was the only one to infer as to the *real* problem here. I
> didn't see the problem until he pointed it out.
> ...
If you are referring to missing 'delete[]' in the first example, I find
it very unlikely to be the source of the problem. The OP probably
removed it by accident when he was preparing the code for posting (with
those "non-germane lines" he mentioned).
The OP's test code is located directly inside function 'main', not
inside some other function. If we assume that this is pretty much
exactly the same code he was trying to benchmark, it becomes clear that
in order to make the running time of the code measurable, he'd have to
use a rather large value of 'NUM'. But with large values of 'NUM' one
missing 'delete[]' cannot and will not result in 6x difference in
running time.
If the code were incapsulated into some other function (say, 'foo') then
it would be logical to suspect that for benchmarking purposes the OP was
trying to call 'foo' for some other cycle (which he didn't show us). In
that case he could use smaller values of 'NUM' and missing 'delete[]'
could contribute to a bigger difference in running time.
There's no way to tell what really happened without some extra
information from the OP, but the most likely reason with the available
code sample is that the OP was trying to benchmark a debugging version
of the code - a very common mistake among MSVC-using "C++ benchmarkers".
-- Best regards, Andrey Tarasevich
- Next message: Josh Lessard: "Initializing unions"
- Previous message: Alf P. Steinbach: "Re: C++ is slow"
- In reply to: Julie: "Re: C++ is slow"
- Next in thread: Julie: "Re: C++ is slow"
- Reply: Julie: "Re: C++ is slow"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|