mirror of
https://gitlab.rlp.net/mobitar/julia_course.git
synced 2024-11-16 13:28:10 +00:00
Improve performance demo
This commit is contained in:
parent
d2a4b883ee
commit
826b6931d3
3 changed files with 13 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
### A Pluto.jl notebook ###
|
||||
# v0.18.4
|
||||
# v0.19.0
|
||||
|
||||
using Markdown
|
||||
using InteractiveUtils
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
### A Pluto.jl notebook ###
|
||||
# v0.18.4
|
||||
# v0.19.0
|
||||
|
||||
using Markdown
|
||||
using InteractiveUtils
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
### A Pluto.jl notebook ###
|
||||
# v0.18.4
|
||||
# v0.19.0
|
||||
|
||||
using Markdown
|
||||
using InteractiveUtils
|
||||
|
@ -410,7 +410,7 @@ md"""
|
|||
"""
|
||||
|
||||
# ╔═╡ 6509dddd-ff17-49db-8e5e-fcea1ef0026c
|
||||
N3 = 1000000
|
||||
N3 = 500000
|
||||
|
||||
# ╔═╡ 2a24aebc-0654-4d00-bdab-627a8e1a75f2
|
||||
# Bad usage of a global array of type Any (container with abstract type)
|
||||
|
@ -418,6 +418,9 @@ begin
|
|||
sin_vals = []
|
||||
|
||||
function global_allocating_access(N)
|
||||
# First, empty the array because @btime runs the function multiple times
|
||||
empty!(sin_vals)
|
||||
|
||||
for i in 1:N
|
||||
push!(sin_vals, sin(i))
|
||||
end
|
||||
|
@ -434,6 +437,9 @@ begin
|
|||
typed_sin_vals = Float64[]
|
||||
|
||||
function typed_global_allocating_access(N)
|
||||
# First, empty the array because @btime runs the function multiple times
|
||||
empty!(typed_sin_vals)
|
||||
|
||||
for i in 1:N
|
||||
push!(typed_sin_vals, sin(i))
|
||||
end
|
||||
|
@ -483,6 +489,9 @@ begin
|
|||
passed_sin_vals = Float64[]
|
||||
|
||||
function local_access(N, sin_vals)
|
||||
# First, empty the array because @btime runs the function multiple times
|
||||
empty!(passed_sin_vals)
|
||||
|
||||
for i in 1:N
|
||||
push!(sin_vals, sin(i))
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue