Created
May 27, 2019 13:11
-
-
Save kanav99/be30a396a91059e1935cee40c83558fe to your computer and use it in GitHub Desktop.
funcwrap
This file contains 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
using OrdinaryDiffEq | |
# First time | |
function lorenz(du,u,p,t) | |
du[1] = 1e6*((1-u[2]*u[2])*u[1] - u[2]) | |
du[2] = 1*u[1] | |
end | |
u0 = [0;2.] | |
tspan = (0.0,6.3) | |
prob = ODEProblem{true,false}(lorenz,u0,tspan) | |
# integ = init(prob,Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e7) | |
@time sol = solve(prob,Rosenbrock23(;autodiff=false),abstol=1/10^5,reltol=1/10^5) | |
#6.820159 seconds (16.06 M allocations: 800.508 MiB, 8.44% gc time) | |
# Enable No-Recompile Mode | |
function lorenz2(du,u,p,t) | |
du[1] = 1e6*((1-u[2]*u[2])*u[1] - u[2]) | |
du[2] = 1*du[1] | |
end | |
prob = ODEProblem{true,false}(lorenz2,u0,tspan) | |
# integ = init(prob,Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e7) | |
@time sol = solve(prob,Rosenbrock23(;autodiff=false),abstol=1/10^5,reltol=1/10^5) | |
#0.004248 seconds (12.96 k allocations: 1.375 MiB) | |
using BenchmarkTools | |
# integ = init(prob, Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e7) | |
@btime sol = solve(prob,Rosenbrock23(;autodiff=false),abstol=1/10^5,reltol=1/10^5) | |
# 1.146 ms (12961 allocations: 1.37 MiB) | |
# Disable No-Recompile Mode | |
function lorenz3(du,u,p,t) | |
du[1] = 1e6*((1-u[2]*u[2])*u[1] - u[2]) | |
du[2] = 1*du[1] | |
end | |
prob = ODEProblem{true}(lorenz3,u0,tspan) | |
@time sol = solve(prob,Rosenbrock23(;autodiff=false),abstol=1/10^5,reltol=1/10^5) | |
#1.839436 seconds (3.97 M allocations: 190.402 MiB, 4.78% gc time) | |
# integ = init(prob,Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e7) | |
@btime sol = solve(prob,Rosenbrock23(;autodiff=false),abstol=1/10^5,reltol=1/10^5) | |
# 1.078 ms (12963 allocations: 1.37 MiB) |
This file contains 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
using OrdinaryDiffEq | |
# First time | |
function lorenz(du,u,p,t) | |
du[1] = 1e6*((1-u[2]*u[2])*u[1] - u[2]) | |
du[2] = 1*u[1] | |
end | |
u0 = [0;2.] | |
tspan = (0.0,6.3) | |
prob = ODEProblem{true,false}(lorenz,u0,tspan) | |
# integ = init(prob,Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e7) | |
@time sol = solve(prob,Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e8) | |
#6.820159 seconds (16.06 M allocations: 800.508 MiB, 8.44% gc time) | |
# Enable No-Recompile Mode | |
function lorenz2(du,u,p,t) | |
du[1] = 1e6*((1-u[2]*u[2])*u[1] - u[2]) | |
du[2] = 1*du[1] | |
end | |
prob = ODEProblem{true,false}(lorenz2,u0,tspan) | |
# integ = init(prob,Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e7) | |
@time sol = solve(prob,Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e8) | |
#0.004248 seconds (12.96 k allocations: 1.375 MiB) | |
using BenchmarkTools | |
# integ = init(prob, Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e7) | |
@btime sol = solve(prob,Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e8) | |
# 1.146 ms (12961 allocations: 1.37 MiB) | |
# Disable No-Recompile Mode | |
function lorenz3(du,u,p,t) | |
du[1] = 1e6*((1-u[2]*u[2])*u[1] - u[2]) | |
du[2] = 1*du[1] | |
end | |
prob = ODEProblem{true}(lorenz3,u0,tspan) | |
@time sol = solve(prob,Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e8) | |
#1.839436 seconds (3.97 M allocations: 190.402 MiB, 4.78% gc time) | |
# integ = init(prob,Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e7) | |
@btime sol = solve(prob,Rosenbrock23(;autodiff=false),abstol=1/10^14,reltol=1/10^14,maxiters=1e8) | |
# 1.078 ms (12963 allocations: 1.37 MiB) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment