decrease the elapse time
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Asliddin Komilov
am 24 Jul. 2019
Beantwortet: Asliddin Komilov
am 4 Aug. 2019
this set of files organized to solve 'environment' function with ranges of different variables. I followed all possible instructions but the elapse time is growing with each iteration inside the script 'Ta_I_yearly_by_azimangle' so I have to take bigger steps. Maybe the whole thing could be organized some other way to make it faster, I don't know, so I need your help here, thanks.
6 Kommentare
Rik
am 24 Jul. 2019
You should use the actual profiler. In most releases that is called 'run and time'. That will show you a breakdown by function and line by line.
Akzeptierte Antwort
Weitere Antworten (2)
Sulaymon Eshkabilov
am 24 Jul. 2019
Hi,
You'd need to associate all of your calc's into one function file and no need to save all variable/calc values from every iteration. Save the only ones that you'd need as outputs from your main function file. ALso, put all of your external fuinction files as a nested functions within your main function file. All these steps should speed up your simulations.
Good luck.
3 Kommentare
Rik
am 25 Jul. 2019
Why suggest such drastic changes before Asliddin has looked at the profiler? Have you tried the profiler yourself and concluded there isn't really a specific line of code that consumes too much time?
Making other functions internal functions also has downsides. It might not be required (or even desirable) to share variables between functions like that.
I suspect the largest gain in performance would be to find a way to express some or all of the loops as array operations.
Jan
am 25 Jul. 2019
The output of the profile is useful - thanks.
The most time is spent here:
[days(:,:,i), time(:,:,:,i), I(:,:,:,i), Ta(:,:,:,i), ...
angle(:,i), Ir(:,:,:,i), Id(:,:,:,i), Gincl(:,:,:,i), r(:,:,:,i)] = ...
Ta_I_yearly_by_angle(azim_angle(i));
But this takes between 36 and 376 seconds. This is not an effect inside Ta_I_yearly_by_angle.
My guess is, that your memory is exhausted and sometime the slow disk caching is used. So please check the memory consumption. during the code runs. Pre-allocating is a good programming style already, but sometimes only more RAM helps.
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!