-4

In order to optimize a program, I want a simple function to show me the exact (or aprox.) speed and memory needed by a function:

measuring("start")
fu()
measuring("stop")
Pablo Lopez
  • 67
  • 2
  • 9

1 Answers1

3

You can use datetime to calculate speed:

from datetime import datetime

startTime = datetime.now()

print(datetime.now() - startTime)

Output: 0:00:00.000007

Just wrap that around your function to time it :).

Have a nice day
  • 1,007
  • 5
  • 11