Skip to content

Commit 08f209f

Browse files
committed
Benchmarks: traverse arrays in cache order
1 parent 7bfee1f commit 08f209f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

benchmark/benchmarks.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ x2d = Array(Float64, 2*dim, 2*dim)
99
y2d = OffsetArray(Float64, -dim + 1 : dim, -dim + 1 : dim)
1010

1111
fill(x) = for i in indices(x,1); x[i] = i; end
12-
fill2d(x) = for i in indices(x,1); for j in indices(x,2); x[i,j] = i + j; end; end
12+
fill2d(x) = for j in indices(x,2); for i in indices(x,1); x[i,j] = i + j; end; end
1313
update(x) = for i in indices(x,1); x[i] = x[i] + i; end
14-
update2d(x) = for i in indices(x,1); for j in indices(x,2); x[i,j] = x[i,j] + i + j; end; end
14+
update2d(x) = for j in indices(x,2); for i in indices(x,1); x[i,j] = x[i,j] + i + j; end; end
1515
update_eachindex(x) = for i in eachindex(x); x[i] = x[i] + i; end
1616

1717
@show @benchmark fill(x)

0 commit comments

Comments
 (0)