How can I make the execution speed consistent while I am testing the speed of the programs?
Mostra commenti meno recenti
I am working on cryptography and testing the execution speed. but when i test the execution speed varies with the same input argument. I was considering the variation comes due to the shared resource by the application that run in the computer. so what shall i do? shall i install MATLAB in virtual box with dedicated resource, if it is possible? Anyone please help me?
Risposta accettata
Più risposte (2)
Walter Roberson
il 24 Gen 2023
Modificato: Walter Roberson
il 24 Gen 2023
0 voti
I am not convinced that virtual machines will be allocated dedicated resources that will not be affected by other activities.
If you are using Windows then:
- safe mode (you might need to use safe mode + internet)
- disable all system services that are not absolutely necessary
- lock the process against particular cores
Yair Altman
il 5 Feb 2023
0 voti
I can certainly understand the desire to use a sandboxed environment that would enable you to optimize the performance of your program without external distractions (for example, background anti-virus checks, OS updates, browser page refreshes etc.). These indeed affect the CPU and memory and therefore your program's executing-time variabiity. As mentioned in the other answers here, there are ways to reduce such distractions to a minimum.
But in addition, note that in real life your program will likely encounter exactly those distractions that you are trying to avoid here. Therefore, optimizing your code for the optimal case (minimal distractions) may possibly make the code sub-optimal for the common case (typical distractions). In most likelihood, you'd rather optimize your code for the typical use-case, not a hypothetical unrealistic optimal use-case.
I'm not saying that sandboxing the application during performance-tuning doesn't have a place, I'm just saying that you should be aware that it has a downside.
One way to work-aroud this limitation is to run the same code using the same inputs multiple times in a loop, and then using the average timing of all these runs. In fact, this is what the builtin timeit funcion does. If you run your code enough times, the effect of spurious distractions from external processes will be minimized, and you'd get a more realistic picture of what your end-user will see. By optimizing the code to make this average run-time faster, you're more likely to get the same effect for end users (some say that it's better to reduce the maximal run-time rather than the average or median, but that's a separate discussion outside of the scope here).
Categorie
Scopri di più su Introduction to Installation and Licensing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!