Why does it take so long to finish?

3 Ansichten (letzte 30 Tage)
Jaki
Jaki am 4 Jul. 2019
Bearbeitet: per isakson am 5 Jul. 2019
So I have a class which runs an algorithm, and I call that class from a script:
the run script looks something like this:
all_time = tic;
% set options
c = Class(options);
toc(all_time)
then the Class function does this:
function obj = Class(options)
class_time = tic;
% some functions
toc(class_time)
end
For some reason, class_time = 242.5 seconds, and all_time = 349.1 seconds. What is happening during those 100 seconds? There is nothing inbetween the two tocs other than ending the class. Why does it take so long to finish being 'busy'?
  1 Kommentar
per isakson
per isakson am 4 Jul. 2019
Bearbeitet: per isakson am 4 Jul. 2019
I modified the code of your question to make it run and received the following result
>> Untitled
Elapsed time is 0.000024 seconds.
Elapsed time is 0.000320 seconds.
There is too little information to provide an answer.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Jaki
Jaki am 4 Jul. 2019
The question isn't about what is in the code, I'm asking about why it takes so long to exit the class. I've looked at the profiler and it didn't tell me anything.
  1 Kommentar
per isakson
per isakson am 5 Jul. 2019
Bearbeitet: per isakson am 5 Jul. 2019
What do you mean by "exit the class" ? What class?
What information do you want to convey with the code in your question?
"why it takes so long" I've never experienced anything of that sort. Thus, I doubt that you correctly interpret your observation.
"the Class function" is that some kind of factory? (It's confusing to use the name, Class, for a function.)

Melden Sie sich an, um zu kommentieren.


Steven Lord
Steven Lord am 5 Jul. 2019
It really depends on what the code represented by "%some functions" does. When the function exits, all the variables (except the ones you're returning) get destroyed. This will cause class objects to be destroyed, memory to be freed, etc. So per isakson is correct -- you haven't provided enough information.
Who knows? Maybe you have an object whose delete method (destructor) has a pause(100) call in it?

Tags

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by