for,while,foreachの速度差を検証してみる [2016/02/20 追記] 全部まとめて書いてしまったので単品で書いたものとILが異なっている可能性有り 個々で検証を行うとまた結果が違うかも・・・ 【検証環境】 ・Unity5.2.4f1(Personal Edition) ・Nexus7(Android 5.0.2) ・100万回ループした際にかかった時間を比較 【比較項目】 ①forの前置インクリメント ②for ③while ④do-while ⑤foreach ⑥forのLengthチェック ⑦forのList<T>参照 ⑧forのList<T>参照のCountチェック ⑨foreachのList<T>参照 ⑩whileのLinkedList<T>参照 ⑪foreachのLinkedList<T>参照 【テストコード】 using UnityEngine; using