diff --git a/test/benchmark.jl b/test/benchmark.jl index 05b453a..748ac53 100644 --- a/test/benchmark.jl +++ b/test/benchmark.jl @@ -69,11 +69,11 @@ end function perf_view(a::Array, i1; rtimes::Int=100000) - et_s, _ = time_view1d(sub(a, i1), rtimes) - et_v, _ = time_view1d(view(a, i1), rtimes) + et_s, _ = time_view1d(Base.view(a, i1), rtimes) + et_v, _ = time_view1d(aview(a, i1), rtimes) et_u, _ = time_view1d(unsafe_aview(a, i1), rtimes) - v = view(a, i1) + v = aview(a, i1) mps_s = mps(v, rtimes, et_s) mps_v = mps(v, rtimes, et_v) mps_u = mps(v, rtimes, et_u) @@ -83,11 +83,11 @@ function perf_view(a::Array, i1; rtimes::Int=100000) end function perf_view(a::Array, i1, i2; rtimes::Int=100000) - et_s, _ = time_view2d(sub(a, i1, i2), rtimes) - et_v, _ = time_view2d(view(a, i1, i2), rtimes) + et_s, _ = time_view2d(Base.view(a, i1, i2), rtimes) + et_v, _ = time_view2d(aview(a, i1, i2), rtimes) et_u, _ = time_view2d(unsafe_aview(a, i1, i2), rtimes) - v = view(a, i1, i2) + v = aview(a, i1, i2) mps_s = mps(v, rtimes, et_s) mps_v = mps(v, rtimes, et_v) mps_u = mps(v, rtimes, et_u) @@ -97,11 +97,11 @@ function perf_view(a::Array, i1, i2; rtimes::Int=100000) end function perf_view(a::Array, i1, i2, i3; rtimes::Int=100000) - et_s, _ = time_view3d(sub(a, i1, i2, i3), rtimes) - et_v, _ = time_view3d(view(a, i1, i2, i3), rtimes) + et_s, _ = time_view3d(Base.view(a, i1, i2, i3), rtimes) + et_v, _ = time_view3d(aview(a, i1, i2, i3), rtimes) et_u, _ = time_view3d(unsafe_aview(a, i1, i2, i3), rtimes) - v = view(a, i1, i2, i3) + v = aview(a, i1, i2, i3) mps_s = mps(v, rtimes, et_s) mps_v = mps(v, rtimes, et_v) mps_u = mps(v, rtimes, et_u) @@ -112,12 +112,12 @@ end # benchmarks -println("Indexing sub view unsafe_aview") +println("Indexing Base.view aview unsafe_aview") println("--------------------------------------------------------------------------------------------------") const a1 = rand(1024) -gc_disable() +gc_enable(false) println("1D views") perf_view(a1, :) @@ -125,11 +125,11 @@ perf_view(a1, 1:1024) perf_view(a1, 1:2:1024) println() -gc_enable() +gc_enable(true) const a2 = rand(32, 32) -gc_disable() +gc_enable(false) println("2D views") perf_view(a2, :, :) @@ -145,11 +145,11 @@ perf_view(a2, 1:2:30, 1:32) perf_view(a2, 1:2:30, 1:2:32) println() -gc_enable() +gc_enable(true) const a3 = rand(16, 8, 8) -gc_disable() +gc_enable(false) println("3D views") perf_view(a3, :, :, :) @@ -189,4 +189,4 @@ perf_view(a3, 1:2:16, 1:2:8, 1:8) perf_view(a3, 1:2:16, 1:2:8, 1:2:8) println() -gc_enable() +gc_enable(true) diff --git a/test/benchmark_construct.jl b/test/benchmark_construct.jl index 0250eb9..1c80d20 100644 --- a/test/benchmark_construct.jl +++ b/test/benchmark_construct.jl @@ -5,14 +5,14 @@ using ArrayViews function traverse_row_subs(a::Array, r::Int) m = size(a, 1) for _ = 1:r, i = 1:m - sub(a, i, :) + Base.view(a, i, :) end end function traverse_row_views(a::Array, r::Int) m = size(a, 1) for _ = 1:r, i = 1:m - view(a, i, :) + aview(a, i, :) end end @@ -26,14 +26,14 @@ end function traverse_column_subs(a::Array, r::Int) n = size(a, 2) for _ = 1:r, i = 1:n - sub(a, :, i) + Base.view(a, :, i) end end function traverse_column_views(a::Array, r::Int) n = size(a, 2) for _ = 1:r, i = 1:n - view(a, :, i) + aview(a, :, i) end end @@ -64,7 +64,7 @@ m1 = 1.0 / et1 m2 = 1.0 / et2 m3 = 1.0 / et3 -@printf("Traverse Rows: subs => %7.4f M/sec views => %7.4f M/sec (%6.3fx) unsafe_views => %7.4f M/sec (%6.3fx)\n", +@printf("Traverse Rows: Base.view => %7.4f M/sec aview => %7.4f M/sec (%6.3fx) unsafe_aview => %7.4f M/sec (%6.3fx)\n", m1, m2, m2 / m1, m3, m3 / m1) # traverse cols @@ -81,5 +81,5 @@ m1 = 1.0 / et1 m2 = 1.0 / et2 m3 = 1.0 / et3 -@printf("Traverse Cols: subs => %7.4f M/sec views => %7.4f M/sec (%6.3fx) unsafe_views => %7.4f M/sec (%6.3fx)\n", +@printf("Traverse Cols: Base.view => %7.4f M/sec aview => %7.4f M/sec (%6.3fx) unsafe_aview => %7.4f M/sec (%6.3fx)\n", m1, m2, m2 / m1, m3, m3 / m1)