MAXScript に関する質問と回答 > 処理速度を上げる方法 > return、break、exit、continue を使用しない |
return、break、exit、continue、throw は、C++ 例外処理に組み込まれています。
C++ 例外は低速です。
テスト ケース: |
fn test1a v = (if v == true do return 1; 0) fn test1b v = (if v == true then 1 else 0) |
100,000 回の繰り返しの場合 |
test1a true -- 15890 msec. test1a false -- 78 msec. test1b true -- 47 msec. test1b false -- 62 msec. |
テスト ケース: |
fn test2a = ( local res for i = 1 to 1000 do if i == 10 do (res = i; break;) res ) fn test2b = ( local notfound = true, res for i = 1 to 1000 while notfound do if i == 10 do (res = i; notfound = false;) res ) |
100,000 回の繰り返しの場合 |
test2a() -- 84265 msec. test2b() -- 1359 msec. |
前のヒント
matchPattern は findString より高速である
次のヒント