Skip to content

Instantly share code, notes, and snippets.

@jamesonthecrow
Last active February 28, 2018 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesonthecrow/de2f4b8b50db8ffe7df49456a8b8fade to your computer and use it in GitHub Desktop.
Save jamesonthecrow/de2f4b8b50db8ffe7df49456a8b8fade to your computer and use it in GitHub Desktop.
Benchmarking neural networks in python
def time_func(function, func_args=None, func_kwargs=None):
"""Time a single call of a function.
Args:
function (function): a function object to time
func_args (list, optional): the args for the function
func_kwargs (dict, optional): the kwargs for the function
Returns:
double: duration of the function call in sections
"""
args = func_args or []
kwargs = func_kwargs or {}
start_time = time.time()
function(*args, **kwargs)
duration = time.time() — start_time
return duration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment