Last active
December 13, 2018 17:04
-
-
Save victorcarrico/cf2cd4f14b427598259e0edc02d5f37e to your computer and use it in GitHub Desktop.
Easy Line Profile Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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