Skip to content

Instantly share code, notes, and snippets.

@msuzen
Last active January 24, 2019 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save msuzen/4b3d3217b8087ea54f379027a23f1836 to your computer and use it in GitHub Desktop.
Save msuzen/4b3d3217b8087ea54f379027a23f1836 to your computer and use it in GitHub Desktop.
Matlab like tic toc functions in Python
# To measure timing
#' http://stackoverflow.com/questions/5849800/tic-toc-functions-analog-in-python
def tic():
# Homemade version of matlab tic and toc functions
import time
global startTime_for_tictoc
startTime_for_tictoc = time.time()
def toc():
import time
if 'startTime_for_tictoc' in globals():
print "Elapsed time is " + str(time.time() - startTime_for_tictoc) + " seconds."
else:
print "Toc: start time not set"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment