S
S
sound9012018-10-09 19:58:32
Python
sound901, 2018-10-09 19:58:32

How to calculate the total execution time of functions?

Tell me how to get the total execution time of functions (a and b) and how to switch to timeit?

def a():
   start_time = time.time()
   print("--- %s sec ---" % (time.time() - start_time))

def b():
   start_time = time.time()
   print("--- %s sec ---" % (time.time() - start_time))

if __name__ == "__main__":
   a()
   b()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2018-10-09
@trofimovdev

def a():
   # do something 1

def b():
   # do something 2

if __name__ == "__main__":
   start_time = time.time()
   a()
   b()
   print("--- %s sec ---" % (time.time() - start_time))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question