Re: Determining item number matching "x" in a list
Re: Determining item number matching "x" in a list
- Subject: Re: Determining item number matching "x" in a list
- From: Steve Cunningham <email@hidden>
- Date: Fri, 14 Mar 2003 11:47:13 -0500
Emmanuel wrote
>
NG's "getindex" requires 170 +or- 25 microseconds
>
My "IndexOfItem" requires 809 +or- 37 microseconds
>
I tested with a list of 20 short strings, for all items successively.
>
(2 x 20 runs, thus). I eliminated the largest value in each list of
>
results (each list had an isolated anomalous value, that's OSX
>
spinning the disk). I repeated 100 times, not 500. Units are
>
microseconds.
I can't reproduce these results :-( I don't mean absolutely, but
relatively. On my machine, using a list of 20 short strings, and testing
for all items successively, I get comparable times for both of these...
and, in fact, for the simple-minded one I submitted earlier. Differences
do emerge for shorter lists, as we both noted... and probably for longer
lists also, where I would expect the binary search to come into it's own
:-)
Perhaps I don't understand your test. What is the "2" in the "2 x 20"
runs? Searching for each item once is 20 runs, right? Where does the 2
come in? Did you do it twice? It also looks like you are timing each
individual search so that for one run you get 2 X 20 = 40 times... and
then you throw out the largest of these and average over them? Then what
do you do with the 100 repetitions? Average the averages? I'm so confused
:-)
I am using a repeat loop that runs through the 20 item list 20 times,(a
total of 400 subroutine calls) for each suggested subroutine, and I time
the whole loop, not the individual calls. sic
set id_2 to punchIn("IndexOfItem") -- a general "Time Clock" I have
written
repeat xTimes times -- property, set to 20
repeat with searchItem in theList -- property, the 20 item list
IndexOfItem(searchItem, theList)
end repeat
end repeat
punchOut(id_2)
Seems like while our absolute times will certainly be different, the
relative rankings should be the same.
Steve
_______________________________________________
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.