Last active
August 22, 2017 07:07
-
-
Save albow-net/a0d25245d649e91c67ac83aebe44dcf3 to your computer and use it in GitHub Desktop.
配列の読み書き速度測定用ソースコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func test_array( N:Int, num:Int ) -> Int { | |
// 長さNの配列を用意し0で初期化 | |
var array = Array<Int>(repeating:0,count:N) | |
// 各要素にnumを代入 | |
for i in 0..<N { | |
array[i] = num | |
} | |
// 各要素の和を計算 | |
var sum = 0 | |
for i in 0..<N { | |
sum += array[i] | |
} | |
return sum | |
} | |
// メイン処理 | |
let N = 1 << 26 | |
let num = 3 | |
for i in 0..<10 { | |
print( test_array( N:N, num:num ) ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment