Execution Speed in 2015a vs. 2014b

1 view (last 30 days)
BCM
BCM on 17 Nov 2015
Edited: BCM on 18 Nov 2015
I'm relatively new to MatLab, and started out with 2014b, where I wrote a finite difference code that calls a small function to calculate a temperature-dependent property. Here is the small function:
function [cp] = heat_capacity_exp(T)
Tmin = 325; %Boundary between low temp cubic and mid temp quartic
Tmax = 350; %Boundary between high temp cubic and mid temp quartic
if(T <= Tmax)
if(T >= Tmin)
cp = 10^7*(-55805.67146 + 661.53705*T - 2.93933*T^2 + 0.0058*T^3 - 4.2937e-6*T^4); %ergs/g-C
else
cp = 10^7*(4.14032 + 0.00715*T - 1.28539e-5*T^2 + 2.1596e-8*T^3); %ergs/g-C
end
else
cp = 10^7*(5.87441 + 0.0193*T - 9.82429e-5*T^2 + 1.20361e-7*T^3); %ergs/g-C
end
return
I used the "Run and Time" process on my entire code and tracked the slowdown to the above function. On 2014b executing this function (my test run called it 11340000 times) took 26.416 sec, but on 2015a it takes 38.346 sec. I'm not sure if the handling of polynomials has changed from 2014b to 2015a, but a 45% increase in execution time seems pretty bad.
Has polynomial handling been changed between 2014b and 2015a? Is there any reason why the code is running so much slower? Thanks!
UPDATE: Profiler indicates that significant time is spent on the "return" and "end" function, not sure why.
UPDATE 2: In further tests, the profiler tells me that the lines that execute (all the ones shown) take up 38% of the time, and that the remaining 62% of the time is taken up by "All other lines"... however, there are no other lines in the code. Why is nearly 2/3 of the time taken up by lines that don't exist?

Answers (0)

Community Treasure Hunt

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

Start Hunting!