Re: C++ is slow

From: Andrey Tarasevich (andreytarasevich_at_hotmail.com)
Date: 03/06/04


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


Relevant Pages

  • Re: [PHP] Re: PHP Brain Teasers
    ... Dice has a new advertisement out there that ... What's missing from your job? ... printf(format, num, location); ...
    (php.general)
  • Re: OT AVIAN FLU
    ... >> Jeff Strickland wrote: ... >>> Using your post as a benchmark, all of the information is missing. ... Prev by Date: ...
    (alt.autos.toyota)
  • Re: Fastcode FillChar B&V ver 1.6.4
    ... It was missing, I uploaded it together with some benchmark results. ... I do not understand why John refuses to update it. ...
    (borland.public.delphi.language.basm)
  • Re: No results populating from SQL Query
    ... mysql_select_dbor die('Error Selecting ... die('Error querying database'.mysql_error()); ... Missing), should be: ... Check here to see what value $num has. ...
    (alt.php)
  • Re: Find Missing Numbers in a List
    ... But hey, slow is faster and better than ... Copy down until you get #NUM! ... errors meaning all the missing values have ... have the missing 4 and 6 and put it in a new column? ...
    (microsoft.public.excel.misc)