Hi all,
I've been testing the difference between MATLAB and python 2.7 (cygwin) implementations of OpenSim in running forward dynamics of a human arm model. Being careful to use the same files/settings and seemingly equivalent timers in MATLAB and Python, and starting/stopping the timer directly before/after the call to run the forward tool, I've noticed that the Python implementation is notably faster than the MATLAB implementation. For example (averaged over 5 trials for accuracy), when simulating 6 seconds of a forward dynamics simulation, MATLAB takes ~150 s while python takes ~ 85 s. With 8 s, MATLAB takes ~250 s while Python takes ~140 s. That is fine, right? If so, might anyone know what the cause is?
Thank you,
Stephanie Hachem
MATLAB vs Python Implementation's Speed Difference
- Stephanie Hachem
- Posts: 34
- Joined: Wed Oct 26, 2016 12:40 pm
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: MATLAB vs Python Implementation's Speed Difference
Yes, a longer simulation should take longer to run; how much longer depends on many things, such as how many integration time steps are taken and, e.g., whether additional memory must be allocated along the way.That is fine, right?
It may be difficult to determine how each second of execution time is being used without running some kind of profiler. MATLAB (Java) and Python are different languages, so different performance is expected. If runtime is a concern, you may want to investigate using C++ as well.might anyone know what the cause is?
- Stephanie Hachem
- Posts: 34
- Joined: Wed Oct 26, 2016 12:40 pm
Re: MATLAB vs Python Implementation's Speed Difference
Hi Dr. Uchida,
I just wanted to be sure that MATLAB time > Python time was expected, or at least not indicative of an error. Interesting; thank you!
Stephanie
I just wanted to be sure that MATLAB time > Python time was expected, or at least not indicative of an error. Interesting; thank you!
Stephanie