Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Executing one function slows down built-in functions in another independent function

2 vues (au cours des 30 derniers jours)
Tien-Ju Yang
Tien-Ju Yang le 3 Juin 2016
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hi,
I encounter a strange speed problem. The problem is that executing one function slows down built-in functions in another independent function. Assume there are two functions, funcA() and funcB(). When I execute only funcB(), it takes 10 seconds. When I execute first funcA() and then funcB(), funcB() now takes 50 seconds. Moreover, if I first type "funcA()" in the command window and run it, and then type "funcB()" in the command window and run it, funcB() takes only 10 seconds. If I write a script as the following: " funcA(); funcB(); " and run this script, funcB() takes 50 seconds. I tried to insert "clear", "clear all" in between. funcB() still takes 50 seconds.
I used "profile" to find what is the part causing the slow down. It turns out some built-in functions become much slower, such as "max" and "bsxfun".
funcA() and funcB() uses different inputs and have no output. I also used breakpoints to check the I/Os of the slow built-in functions. The I/Os are exactly the same across all experiments.
I also used "top" to check the memory usage, but in all experiments I have a lot of free memory.
Does anyone have an idea about what is going on or how to debug this?
Thanks!
  2 commentaires
Matt J
Matt J le 3 Juin 2016
Modifié(e) : Matt J le 3 Juin 2016
Were any of these tests done inside a function mfile as opposed to the command line or scripts? It's important to test that because the JIT is only active inside mfunctions, I believe.
Walter Roberson
Walter Roberson le 3 Juin 2016
JIT is active inside scripts as of R2016a.

Réponses (0)

Cette question est clôturée.

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by