title: What is the best way to get the execution time spent of a single line of code?
body: <p>I am trying to get the execution time spent on a single line of code. Doing this for multiple lines and/or writing code every time like in the example below is just frustrating. Is there a better way to do this? See the example below. </p>
  
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  import datetime
  
  start_time = datetime.datetime.now()
  df = pd.read_csv('dummy.csv')
  print('Time spent reading: {}'.format(datetime.datetime.now() - start_time))
  start_time = datetime.datetime.now()
  df.head(n=100)
  print('Time spent printing top 100: {}'.format(datetime.datetime.now() - start_time)) 
  </code></pre>