How to speed up a code from the Code Profiler Results ?

조회 수: 1 (최근 30일)
Jinsu Kim
Jinsu Kim 2020년 7월 14일
편집: Jinsu Kim 2020년 7월 14일
I want to imrpove my code speed, so I did code profiling analysis.
Below is the result of code profiler but I have no idea how to start with these results.
I used ode15s solver, and results seems that bottleneck contained in ode15s solver which means I did not manually write these codes.
The most time consuming lines are:
line 131: Fdel(:,j) = feval(F,Fargs{1:diffvar-1},ydel(:,j),Fargs{diffvar+1:end})
line 148: dFdy = Fdiff * diag(1 ./ del);
line 126 : ydel = y(:,ones(1,ny)) + diag(del);
It accounts on the total computing time 77.1 %, 19.3 % respectively.
Tolerance option change in ode15s solver was not the answer..
In this case, is there any troubleshooting method to enhance the code speed?
Thanks in advances :D

채택된 답변

Yair Altman
Yair Altman 2020년 7월 14일
Try to set the "Vectorized" property using the odeset function, before running ode45. Also, specifying the Jacobian in advance (if you know it) can speed up the calculation - set the "Jacobian" and optionally "JPattern" properties of odeset, Take a look at the other options to see if you can give the solver more information about your function - the more information that the solver has, the more likely it is to use an optimized computation.
  댓글 수: 1
Jinsu Kim
Jinsu Kim 2020년 7월 14일
편집: Jinsu Kim 2020년 7월 14일
Thanks for your reply :)
Unfortunately, I don't know my Jacobian matrix. Anyway, now I'm trying to convert m.file to Cmex file. I hope it works.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by