Created
March 2, 2021 15:53
-
-
Save Arkoniak/6f8399522fc0d866cf5a400961ff5810 to your computer and use it in GitHub Desktop.
File for testing view speed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f1(v) | |
v1 = deepcopy(v) | |
stats = @timed sort!(v1) | |
return stats.time*1.0e6 | |
end | |
function f2(v) | |
v1 = deepcopy(v) | |
v2 = @views v1[500:1499] | |
stats = @timed sort!(v2) | |
return stats.time*1.0e6 | |
end | |
function main(n = 100000) | |
v1 = parse.(Float64, split(read(joinpath(@__DIR__, "data.txt"), String))) | |
results = Vector{Float64}(undef, n) | |
for i in 1:n | |
results[i] = f1(v1) | |
end | |
m1 = minimum(results) | |
v2 = Vector{Float64}(undef, 2000) | |
v2[500:1499] .= v1 | |
for i in 1:n | |
results[i] = f2(v2) | |
end | |
m2 = minimum(results) | |
return m1, m2 | |
end | |
println(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment