Re: Strange Bottleneck
Re: Strange Bottleneck
- Subject: Re: Strange Bottleneck
- From: Nigel Garvey <email@hidden>
- Date: Sat, 7 Jun 2003 10:59:06 +0100
Steve Cunningham wrote on Thu, 5 Jun 2003 17:04:32 -0400:
>
I have written a script to handle matrices or tables in AppleScript.
>
Works great... except as the size of the matrix gets larger, the time to
>
stuff the matrix increases in an anomalous, non-linear manner. To
>
illustrate, I have included only the code to generate the matrix by rows
>
below. The problem is that when adding rows, the columns take 10 times
>
longer to generate for the later rows than for the earlier rows. The
>
problem is the line:
>
>
set item nn of columns to insert_listitem(item nn of columns, item nn of
>
valueList, newRow)
>
>
which I have highlighted in the listing.
>
>
What I am having difficulty in understanding is why the time to build a
>
given column should increase almost by an order of magnitude from the
>
first to the last. Once the first row is built, the number of columns and
>
the number of items in the valuelist are constant, so why should I be
>
seeing such wide variation? In the example below, every iteration handles
>
exactly 90 values for each row. I can't see any material difference
>
between row 2 and row 40, yet the colums are updated for row 2 in 4 ms
>
while it takes 34 ms to update row 40.
This seems to be connected with the time it takes to access 'item nn of
columns'. The "Serge" method for speeding up list-item access makes a
great difference here (on my machine). Try changing the line you've
quoted above to:
set item nn of my columns to insert_listitem(item nn of my columns,
item nn of valueList, newRow)
"Me" in this case is the script object 'matrix'. By refering to its
property 'columns' as 'my columns', you're using a reference to the
property rather than the property itself, which is much faster (for
various arcane reasons) when accessing numbered items in the list.
I still get one or two timings that stand out as being much longer than
the others, but these seem to be more to do with random factors on my
machine than with the script itself.
NG
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.