Skip to content

Instantly share code, notes, and snippets.

@rdammkoehler
Created October 10, 2024 20:10
Show Gist options
  • Save rdammkoehler/b3bf2aa1d91386a61f925cac8764ec70 to your computer and use it in GitHub Desktop.
Save rdammkoehler/b3bf2aa1d91386a61f925cac8764ec70 to your computer and use it in GitHub Desktop.
Python Timing Decorator (simple)
import logging
from datetime import datetime
import time
def timed(method):
def _timed(*args, **kwargs):
start_time = time.time()
result = method(*args, **kwargs)
end_time = time.time()
logging.debug(
'{0}\t{1!r}\t{2:2.2f} ms\n'.format(datetime.now(), method.__name__, (end_time - start_time) * 1000))
return result
return _timed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment