Skip to content

Instantly share code, notes, and snippets.

@albow-net
Last active August 22, 2017 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albow-net/a0d25245d649e91c67ac83aebe44dcf3 to your computer and use it in GitHub Desktop.
Save albow-net/a0d25245d649e91c67ac83aebe44dcf3 to your computer and use it in GitHub Desktop.
配列の読み書き速度測定用ソースコード
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