Can you measure the performance of a function that calls multiple functions within using 'timeit'?

1 次查看(过去 30 天)
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 个评论
Rik
Rik 2019-10-16
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by