Skip to content

Commit 95db2e1

Browse files
committed
Update the benchmarks
1 parent f245c6a commit 95db2e1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

benchmark/benchmarks.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ using OffsetArrays
33

44
const dim = 1000
55

6-
x = Array(Float64, 2*dim)
7-
y = OffsetArray(Float64, -dim + 1 : dim)
8-
x2d = Array(Float64, 2*dim, 2*dim)
9-
y2d = OffsetArray(Float64, -dim + 1 : dim, -dim + 1 : dim)
6+
x = Array{Float64}(undef, 2*dim)
7+
y = OffsetArray{Float64}(undef, -dim + 1 : dim)
8+
x2d = Array{Float64}(undef, 2*dim, 2*dim)
9+
y2d = OffsetArray{Float64}(undef, -dim + 1 : dim, -dim + 1 : dim)
1010

11-
fill(x) = for i in indices(x,1); x[i] = i; end
12-
fill2d(x) = for j in indices(x,2); for i in indices(x,1); x[i,j] = i + j; end; end
13-
update(x) = for i in indices(x,1); x[i] = x[i] + i; 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
11+
fill(x) = for i in axes(x,1); x[i] = i; end
12+
fill2d(x) = for j in axes(x,2); for i in axes(x,1); x[i,j] = i + j; end; end
13+
update(x) = for i in axes(x,1); x[i] = x[i] + i; end
14+
update2d(x) = for j in axes(x,2); for i in axes(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

17-
unsafe_fill(x) = @unsafe(for i in indices(x,1); x[i] = i; end)
18-
unsafe_fill2d(x) = @unsafe(for j in indices(x,2); for i in indices(x,1); x[i,j] = i + j; end; end)
19-
unsafe_update(x) = @unsafe(for i in indices(x,1); x[i] = x[i] + i; end)
20-
unsafe_update2d(x) = @unsafe(for j in indices(x,2); for i in indices(x,1); x[i,j] = x[i,j] + i + j; end; end)
21-
unsafe_update_eachindex(x) = @unsafe(for i in eachindex(x); x[i] = x[i] + i; end)
17+
unsafe_fill(x) = @inbounds(for i in axes(x,1); x[i] = i; end)
18+
unsafe_fill2d(x) = @inbounds(for j in axes(x,2); for i in axes(x,1); x[i,j] = i + j; end; end)
19+
unsafe_update(x) = @inbounds(for i in axes(x,1); x[i] = x[i] + i; end)
20+
unsafe_update2d(x) = @inbounds(for j in axes(x,2); for i in axes(x,1); x[i,j] = x[i,j] + i + j; end; end)
21+
unsafe_update_eachindex(x) = @inbounds(for i in eachindex(x); x[i] = x[i] + i; end)
2222

2323
@show @benchmark fill(x)
2424
@show @benchmark fill(y)

0 commit comments

Comments
 (0)