Can you measure the performance of a function that calls multiple functions within using 'timeit'?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to use timeit (or tic-toc) to measure the performance of a function. I am calling this function within a loop to measure the timing information multiple times and then averaging. When I run this function once, suppose the timing is measured to be m1±s1 (mean±standard deviation) across N runs (in the loop that I mentioned). The standard deviation is not very high, quite acceptable. However, if I execute this loop again, say in an hour, it becomes m2±s2, the mean changes to m2 which is quite different from m1. s2 however remains small. Can I know how to use timeit properly? What factors does it depend on?
P.S. I am NOT doing the following within the functions (as mentioned in the timeit documentation)
- Using timeit between tic and toc
- Using timeit to time a function that includes calls to tic and toc
- Using timeit recursively
4 Kommentare
Rik
am 16 Okt. 2019
I don't think that should matter, as long as you run the function with the same input.
If your function contacts some server, there will be a dependency on your internet connection, but I don't see any such external factors in your description.
Also, your question is not urgent, the reason for that is explained here. I therefore removed that part from your question title.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!