We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seems like the MTK-generated is ~5x slower than a corresponding hand-written function
using ModelingToolkit using BenchmarkTools using SciMLBase t = ModelingToolkit.t_nounits; D = ModelingToolkit.D_nounits @parameters α β γ δ @variables x(t) y(t) eqs = [D(x) ~ α * x - β * x * y, D(y) ~ -γ * y + δ * x * y] @mtkbuild sys = ODESystem(eqs, t) f1 = ODEFunction(sys) f2 = ODEFunction(sys; eval_expression = true) f3 = ODEFunction{true, SciMLBase.FullSpecialize}(sys) f4 = ODEFunction{true, SciMLBase.FullSpecialize}(sys; eval_expression = true) function lotkavolterra!(du, u, p, t) du[1] = p[1]*u[1] - p[2]*u[1]*u[2] du[2] = -p[4]*u[2] + p[3]*u[1]*u[2] end du = zeros(2); u = rand(2); p = rand(4); t_ = 0. @btime f1(du,u,p,t_) # 93.335 ns du = zeros(2) @btime f2(du,u,p,t_) # 92.068 ns du = zeros(2) @btime f3(du,u,p,t_) # 88.889 ns du = zeros(2) @btime f4(du,u,p,t_) # 85.842 ns du = zeros(2) @btime lotkavolterra!(du,u,p,t_) # 17.368 ns
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Seems like the MTK-generated is ~5x slower than a corresponding hand-written function
The text was updated successfully, but these errors were encountered: