Skip to content

Commit 16653b0

Browse files
committed
Don't use global variables in the benchmarks
1 parent 22c4f60 commit 16653b0

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

benchmark/benchmarks.jl

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@ const dim = 1000
66
x = Array(Float64, 2*dim)
77
y = OffsetArray(Float64, -dim + 1 : dim)
88

9-
fillx() = for i = 1:2*dim x[i] = i end
10-
filly() = for i = -dim+1:dim y[i] = i end
11-
updatex() = for i = 1:2*dim x[i] = x[i] + i end
12-
updatey() = for i = -dim+1:dim y[i] = y[i] + i end
13-
updatex_eachindex() = for i in eachindex(x) x[i] = x[i] + i end
14-
updatey_eachindex() = for i in eachindex(y) y[i] = y[i] + i end
15-
16-
@benchmark fillx()
17-
@benchmark filly()
18-
@benchmark updatex()
19-
@benchmark updatey()
20-
@benchmark updatex_eachindex()
21-
@benchmark updatey_eachindex()
9+
fillx(x) = for i in indices(x,1); x[i] = i; end
10+
updatex(x) = for i in indices(x,1); x[i] = x[i] + i; end
11+
updatex_eachindex(x) = for i in eachindex(x); x[i] = x[i] + i; end
2212

13+
@show @benchmark fillx(x)
14+
@show @benchmark fillx(y)
15+
@show @benchmark updatex(x)
16+
@show @benchmark updatex(y)
17+
@show @benchmark updatex_eachindex(x)
18+
@show @benchmark updatex_eachindex(y)

0 commit comments

Comments
 (0)