2 single: 性能改善に関する情報; はじめに
12 pair: 性能改善に関する情報; リストの作成
21 ? "Create the list using the Range operator"
24 ? "Time : " + ((clock()-t1)/clockspersecond()) + " seconds"
26 ? "Create the list using the For loop"
32 ? "Time : " + ((clock()-t1)/clockspersecond()) + " seconds"
34 ? "Create the list using the list() function and the For loop"
40 ? "Time : " + ((clock()-t1)/clockspersecond()) + " seconds"
46 Create the list using the Range operator
48 Create the list using the For loop
50 Create the list using the list() function and the For loop
53 .. note:: リストの作成で for ループ、または list() 関数を使用するよりも、範囲演算子のほうが速いです。
55 .. note:: リストの追加で add() 関数を使用するよりも、連結演算子‘+’を使用したほうが関数呼び出しのオーバーヘッドが少ないため速いです。ただしソースコードの可読性は落ちる場合があります。
57 .. note:: 処理に時間が掛かり過ぎるため copy() 関数で数十万件を超える大量のテストデータを作成しないでください。
60 pair: 性能改善に関する情報; 算術演算子
74 ? "Time : " + ((clock()-t1)/clockspersecond()) + " seconds"
82 ? "Time : " + ((clock()-t1)/clockspersecond()) + " seconds"
93 .. note:: \* 演算子よりも \*= 演算子を使用したほうが速いです。
97 pair: 性能改善に関する情報; len() と For ループの使用
100 =========================
108 ? "Using len() in the For loop"
110 for x = 1 to len(aList)
112 ? "Time : " + ((clock()-t1)/clockspersecond()) + " seconds"
114 ? "Using len() before the For loop"
119 ? "Time : " + ((clock()-t1)/clockspersecond()) + " seconds"
125 Using len() in the For loop
127 Using len() before the For loop
130 .. note:: Len() 関数は For ループ内ではなく For ループの手前で使用したほうが早いです。
133 pair: 性能改善に関する情報; 関数とメソッドの呼び出し
136 ========================
142 ? "calling 100000 functions"
147 ? "Time : " + ((clock()-t1)/clockspersecond()) + " seconds"
151 ? "calling 100000 methods using the dot operator"
156 ? "Time : " + ((clock()-t1)/clockspersecond()) + " seconds"
158 ? "calling 100000 methods using braces "
163 ? "Time : " + ((clock()-t1)/clockspersecond()) + " seconds"
176 calling 100000 functions
178 calling 100000 methods using the dot operator
180 calling 100000 methods using braces
183 .. note:: メソッドの呼び出しよりも、関数の呼び出しのほうが僅かに速いです。
185 .. note:: メソッドの呼び出しで弓括弧を使用するよりも、ドット演算子を使用したほうが速いです。