●レコード内のリストの参照
レコード内のリストの参照は、普通にリストを参照する場合と比べ、どの位余計に時間がかかるのかを調べようと思い実験してみました。
意外にもレコード内のリストの参照の方が5倍以上速いという実験結果が出ました。
これまで実験に使っていたソートのハンドラでは、部分的にこの方法をとっていましたが、すべてでこの方法をとればもっと速くなりそうです。
set theRec to {aList:{}}
set theRecRef to a reference to theRec
set n to {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
set theList to {}
set theListRef to a reference to theList
repeat 1000 times
set end of theListRef to (some item of n) * 100 + (some item of n) * 10 + (some item of n)
end repeat
set aList of theRecRef to theList
set timeList to {}
--リストの参照から要素を取り出した場合
set T to current date
repeat 1000000 times
set A to item 500 of theListRef
end repeat
set end of timeList to (current date) - T
--レコードの参照の中のリストから要素を取り出した場合
set T to current date
repeat 1000000 times
set A to item 500 of aList of theRecRef
end repeat
set end of timeList to (current date) - T
--単に変数名を付けただけの場合
set T to current date
repeat 1000000 times
set B to A
end repeat
set end of timeList to (current date) - T
get timeList
結果{48, 9, 2}