Skip to content

Instantly share code, notes, and snippets.

@victorcarrico
Last active December 13, 2018 17:04
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 victorcarrico/cf2cd4f14b427598259e0edc02d5f37e to your computer and use it in GitHub Desktop.
Save victorcarrico/cf2cd4f14b427598259e0edc02d5f37e to your computer and use it in GitHub Desktop.
Easy Line Profile Example
from line_profiler import LineProfiler
import random
def do_stuff(numbers):
s = sum(numbers)
l = [numbers[i]/43 for i in range(len(numbers))]
m = ['hello'+str(numbers[i]) for i in range(len(numbers))]
numbers = [random.randint(1,100) for i in range(1000)]
lp = LineProfiler()
lp_wrapper = lp(do_stuff)
lp_wrapper(numbers)
lp.print_stats()
# https://stackoverflow.com/questions/23885147/how-do-i-use-line-profiler-from-robert-kern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment