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

조회 수: 4 (최근 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에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by