C (277/301)

From:Allan Odgaard
Date:18 Aug 99 at 22:08:45
Subject:Re: Structure Arrays

From: Allan Odgaard <Duff@DIKU.DK>

On 18-Aug-99, Christian Hattemer wrote:

> I would say the opposite: Insert_Single could be a wrapper for Insert to
> reduce complexity, since "MUIM_List_Insert has caused some confusion".

That's something I hadn't noticed - but I'd still argue that Insert is done by
traversing the array, and calling InsertSingle for each item. The list is not
able to use the array in any way a) because it'll be disposed after the
method is done and b) because the list stores its entries in a linked list.

Tell you what, I'll do a speed test:

50.000 items:
Insert: 1.84 seconds
InsertSingle: 3.42 seconds

100.000 items:
Insert: 6.50 seconds
InsertSingle: 9.62 seconds

200.000 items:
Insert: 24.68 seconds
InsertSingle: 31.08 seconds

I admit that Insert is faster, but notice that InsertSingle gets closer and
closer to the time of Insert. I'd imagine that the reason why InsertSingle is
slower is either because Stefan calls InsertSingle internally (i.e. without
going through the dispatcher) and/or because I used StormCPP where Stefan has
used SAS/C for the loop that calls MUIM_List_InsertSingle. And with 200.000
iterations then a single instruction saved does show in the end result ;-)

Regards Allan



URL: http://www.DIKU.dk/students/duff/


Reality is for people who lack imagination.