Created
December 9, 2014 11:52
-
-
Save tadzik/208b32c893a799df26d4 to your computer and use it in GitHub Desktop.
This file contains 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
┌─[tadzik@yavin]─[~] | |
└─[%]─> cat test.py | |
from urlparse import urlsplit | |
import cProfile, pstats, StringIO | |
pr = cProfile.Profile() | |
pr.enable() | |
u = urlsplit("www.google.com/foo/bar?argh=fuuu#baz", "http") | |
a = [] | |
for i in xrange(1000): | |
a.append(u.hostname) | |
pr.disable() | |
s = StringIO.StringIO() | |
sortby = 'cumulative' | |
ps = pstats.Stats(pr, stream=s).sort_stats(sortby) | |
ps.print_stats() | |
print s.getvalue() | |
┌─[tadzik@yavin]─[~] | |
└─[%]─> python test.py | |
3009 function calls in 0.002 seconds | |
Ordered by: cumulative time | |
ncalls tottime percall cumtime percall filename:lineno(function) | |
1000 0.001 0.000 0.002 0.000 /usr/lib/python2.7/urlparse.py:95(hostname) | |
1002 0.000 0.000 0.000 0.000 {method 'split' of 'str' objects} | |
1000 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} | |
1 0.000 0.000 0.000 0.000 /usr/lib/python2.7/urlparse.py:168(urlsplit) | |
1 0.000 0.000 0.000 0.000 <string>:8(__new__) | |
1 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects} | |
1 0.000 0.000 0.000 0.000 {built-in method __new__ of type object at 0x93b580} | |
1 0.000 0.000 0.000 0.000 {method 'find' of 'str' objects} | |
1 0.000 0.000 0.000 0.000 {len} | |
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment