Skip to content

Commit 0c68a47

Browse files
committed
add openmodelica timings
1 parent dcf346a commit 0c68a47

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

benchmarks/ModelingToolkit/Multibody_Robot.jmd

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using Pkg
99

1010
using ModelingToolkit
1111
using Multibody
12+
using Multibody: Robot6DOF
1213
using JuliaSimCompiler
1314
using OrdinaryDiffEq
1415
using CairoMakie
@@ -65,6 +66,54 @@ barplot(f[2,1], timings, axis=(; title="Log Timings", xticks = (xs, labels), ysc
6566
f
6667
```
6768

69+
## OpenModelica
70+
71+
```julia
72+
cd(@__DIR__)
73+
using Pkg
74+
Pkg.activate(".")
75+
using OMJulia
76+
mod = OMJulia.OMCSession();
77+
OMJulia.sendExpression(mod, "getVersion()")
78+
79+
@show "Start OpenModelica Timings"
80+
81+
totaltime = @elapsed begin
82+
om_build = @elapsed ModelicaSystem(mod, modelName="Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.FullRobot", library="Modelica")
83+
om_sim = @elapsed res = sendExpression(mod, "simulate(Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.FullRobot)")
84+
end
85+
@assert res["messages"][1:11] == "LOG_SUCCESS"
86+
87+
OMJulia.quit(mod)
88+
```
89+
90+
## Comparison
91+
```julia
92+
colors = Makie.wong_colors()
93+
labels = ["Build", "Simulate"]
94+
julia_build = time_instantiate + time_simplify + time_prob + time_extract_data
95+
julia_sim = time_solve
96+
97+
data = [
98+
julia_build julia_sim
99+
om_build om_sim
100+
]
101+
102+
xs = repeat(1:length(labels), inner=2)
103+
group = repeat([1,2], outer=2)
104+
fig = Figure()
105+
barplot(fig[1,1], xs, vec(data), dodge=group, color=colors[group], axis=(; title="Timings", xticks = ([1,2], labels)))
106+
107+
# Legend
108+
legendentries = ["Julia", "OpenModelica"]
109+
elements = [PolyElement(polycolor = colors[i]) for i in 1:length(legendentries)]
110+
title = "Contestants"
111+
112+
Legend(fig[1,2], elements, legendentries, title)
113+
fig
114+
```
115+
116+
68117
## Appendix
69118

70119
```julia, echo = false

0 commit comments

Comments
 (0)