tic, toc, apear to be reporting incorrect times when called in App Designer button callback
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
AdamG2013468
le 31 Juil 2019
Commenté : Walter Roberson
le 1 Août 2019
I am using App Designer to build an app that, among other things, imports a .csv after pressing an "import" button.
The callback function for this import button includes only about 80 lines of code, but by my estimates takes approximately 30sec-1.5 min. I placed the "tic" function at the beginning of the callback function, and the "toc" function at the end. I also have an edit text field that reads out the current status of the import callback. Using the status edit field as reference, i can tell how long the callback function is "Processing...". My issue is that when the toc value is returned to the workspace and my EditField value, it is calculating the stop watch time as approximately 1.5 seconds, when it is more like 1 min. For example, my code follows the format below.
function ImportButtonPushed(app, event)
tic
app.EditField.Value = 'Processing';
%80-90 lines of code
toc
app.EditField.Value = sprintf('Completed: Processing Time = %f', toc)
end
Has anyone experience similar issues before? Or am I making a simple mistake?
2 commentaires
Adam
le 1 Août 2019
I tend to use the profiler rather than tic toc when I want to examine multiple lines of code, especially involving builtin functions and implicitly called ones, e.g. you will often find drawnow takinga lot of time where a GUI is concerned. I've often found java GUI component rendering to be quite slow, though I often use the GUI Layout Toolbox and one of the flaws of the layouts is their effect on speed and calls to drawnow.
Walter Roberson
le 1 Août 2019
Unfortunately the profiler tends to disable JIT, and so can give very different timings than production code.
Réponse acceptée
Stephen23
le 1 Août 2019
Try specifying the output variable:
t = tic();
...
toc(t)
Or record the time yourself:
tstart = now();
...
now()-tstart
(multiply by 24*60*60 to get seconds)
4 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!