0

I am running a program in Google Colab. I am using time module to compute the time of execution like start=time.time();....end=time.time(). Every time I run the code it's execution time is varying.

Is there a way I can find the average execution time or some other function I can use to resolve this.

I am running the same code using Linux Terminal. So It is appreciated even if I can find the average time of execution while running the python program from Linux Terminal.

1 Answers1

0

There are multiple solutions to this problem.

  1. If you want to test a function or piece of code, you can write a script that does your own calculations with the help of a decorator.

  2. you can make use of existing libraries.

I think there are enough examples for both options in the following title; How do I get time of a Python program's execution?

If there is something you cannot do specifically other than these, if you write, I can help.

Sezer BOZKIR
  • 534
  • 2
  • 13
  • I believe these solutions also give variable time. Have you tested with any code? –  Dec 16 '22 at 03:43
  • These solutions test and average the code snippet you write over and over. It depends on the code you wrote. And yes, for example, I saw average differences in random tests I did for migrations and sql queries. – Sezer BOZKIR Dec 16 '22 at 09:59