@@ -5,14 +5,22 @@ const dim = 1000
5
5
6
6
x = Array (Float64, 2 * dim)
7
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)
8
10
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
11
+ 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
13
+ 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
15
+ update_eachindex (x) = for i in eachindex (x); x[i] = x[i] + i; end
12
16
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)
17
+ @show @benchmark fill (x)
18
+ @show @benchmark fill (y)
19
+ @show @benchmark fill2d (x2d)
20
+ @show @benchmark fill2d (y2d)
21
+ @show @benchmark update (x)
22
+ @show @benchmark update (y)
23
+ @show @benchmark update2d (x2d)
24
+ @show @benchmark update2d (y2d)
25
+ @show @benchmark update_eachindex (x)
26
+ @show @benchmark update_eachindex (y)
0 commit comments