How would you create a decorator to measure the execution time of a function?

  • By adding timestamps manually at the beginning and end of the function.
  • By using the @timer decorator.
  • By wrapping the function with timeit module functions.
  • Python does not support measuring execution time with decorators.
You can create a decorator to measure execution time by adding timestamps manually at the start and end of the function, then calculating the time elapsed. This allows you to track how long a function takes to execute.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *