Skip to content

Instantly share code, notes, and snippets.

@firesofmay
Created January 7, 2012 06:58
Show Gist options
  • Save firesofmay/1574040 to your computer and use it in GitHub Desktop.
Save firesofmay/1574040 to your computer and use it in GitHub Desktop.
#Py Code tested
import urllib2
import cProfile
def main():
url = "http://majorgeeks.com/page.php?id="
for i in xrange(1,21):
tempurl = url + str(i)
res = urllib2.urlopen(tempurl)
if __name__ == '__main__':
cProfile.run('main()')
main()
#Profiler Output:
9462 function calls (9367 primitive calls) in 11.728 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 11.728 11.728 <string>:1(<module>)
20 0.000 0.000 0.000 0.000 <string>:8(__new__)
1 0.000 0.000 0.000 0.000 UserDict.py:40(items)
180 0.000 0.000 0.001 0.000 httplib.py:220(addheader)
20 0.003 0.000 0.010 0.000 httplib.py:234(readheaders)
20 0.000 0.000 0.001 0.000 httplib.py:335(__init__)
20 0.000 0.000 5.493 0.275 httplib.py:363(_read_status)
20 0.001 0.000 5.505 0.275 httplib.py:400(begin)
20 0.000 0.000 0.000 0.000 httplib.py:486(_check_close)
20 0.000 0.000 0.001 0.000 httplib.py:516(close)
20 0.000 0.000 0.000 0.000 httplib.py:680(__init__)
20 0.000 0.000 0.000 0.000 httplib.py:710(_set_hostport)
20 0.000 0.000 0.000 0.000 httplib.py:727(set_debuglevel)
20 0.000 0.000 6.203 0.310 httplib.py:751(connect)
20 0.000 0.000 0.000 0.000 httplib.py:759(close)
20 0.000 0.000 6.204 0.310 httplib.py:769(send)
100 0.000 0.000 0.000 0.000 httplib.py:789(_output)
20 0.000 0.000 6.205 0.310 httplib.py:796(_send_output)
20 0.000 0.000 0.001 0.000 httplib.py:817(putrequest)
80 0.001 0.000 0.001 0.000 httplib.py:927(putheader)
20 0.000 0.000 6.205 0.310 httplib.py:938(endheaders)
20 0.000 0.000 6.206 0.310 httplib.py:953(request)
20 0.000 0.000 6.206 0.310 httplib.py:974(_send_request)
20 0.000 0.000 5.507 0.275 httplib.py:991(getresponse)
20 0.000 0.000 0.011 0.001 mimetools.py:24(__init__)
20 0.000 0.000 0.001 0.000 mimetools.py:33(parsetype)
20 0.000 0.000 0.000 0.000 mimetools.py:50(parseplist)
3 0.000 0.000 0.002 0.001 re.py:188(compile)
3 0.000 0.000 0.002 0.001 re.py:228(_compile)
180 0.001 0.000 0.001 0.000 rfc822.py:197(isheader)
200 0.000 0.000 0.000 0.000 rfc822.py:209(islast)
200 0.000 0.000 0.000 0.000 rfc822.py:219(iscomment)
120 0.000 0.000 0.000 0.000 rfc822.py:285(getheader)
20 0.000 0.000 0.010 0.000 rfc822.py:88(__init__)
20 0.001 0.000 0.001 0.000 socket.py:185(__init__)
20 0.000 0.000 0.000 0.000 socket.py:192(close)
20 0.000 0.000 0.000 0.000 socket.py:212(makefile)
40 0.000 0.000 5.406 0.135 socket.py:223(meth)
40 0.000 0.000 0.000 0.000 socket.py:246(__init__)
60/20 0.001 0.000 0.002 0.000 socket.py:276(close)
40/20 0.000 0.000 0.002 0.000 socket.py:285(__del__)
40 0.000 0.000 0.000 0.000 socket.py:292(flush)
220 0.003 0.000 5.497 0.025 socket.py:406(readline)
20 0.001 0.000 6.202 0.310 socket.py:537(create_connection)
2 0.000 0.000 0.000 0.000 sre_compile.py:178(_compile_charset)
2 0.000 0.000 0.000 0.000 sre_compile.py:207(_optimize_charset)
8 0.000 0.000 0.000 0.000 sre_compile.py:24(_identityfunction)
13/3 0.000 0.000 0.001 0.000 sre_compile.py:32(_compile)
5 0.000 0.000 0.000 0.000 sre_compile.py:354(_simple)
3 0.000 0.000 0.000 0.000 sre_compile.py:361(_compile_info)
6 0.000 0.000 0.000 0.000 sre_compile.py:474(isstring)
3 0.000 0.000 0.001 0.000 sre_compile.py:480(_code)
3 0.000 0.000 0.002 0.001 sre_compile.py:495(compile)
20 0.000 0.000 0.000 0.000 sre_parse.py:126(__len__)
40 0.000 0.000 0.000 0.000 sre_parse.py:130(__getitem__)
5 0.000 0.000 0.000 0.000 sre_parse.py:134(__setitem__)
19 0.000 0.000 0.000 0.000 sre_parse.py:138(append)
18/8 0.000 0.000 0.000 0.000 sre_parse.py:140(getwidth)
3 0.000 0.000 0.000 0.000 sre_parse.py:178(__init__)
49 0.000 0.000 0.000 0.000 sre_parse.py:182(__next)
36 0.000 0.000 0.000 0.000 sre_parse.py:195(match)
38 0.000 0.000 0.000 0.000 sre_parse.py:201(get)
8/3 0.000 0.000 0.001 0.000 sre_parse.py:301(_parse_sub)
8/3 0.000 0.000 0.001 0.000 sre_parse.py:379(_parse)
3 0.000 0.000 0.001 0.000 sre_parse.py:663(parse)
3 0.000 0.000 0.000 0.000 sre_parse.py:67(__init__)
5 0.000 0.000 0.000 0.000 sre_parse.py:72(opengroup)
5 0.000 0.000 0.000 0.000 sre_parse.py:83(closegroup)
13 0.000 0.000 0.000 0.000 sre_parse.py:90(__init__)
1 0.001 0.001 11.728 11.728 testingpy.py:5(main)
20 0.000 0.000 0.000 0.000 urllib.py:1001(__init__)
20 0.000 0.000 0.000 0.000 urllib.py:1007(info)
20 0.000 0.000 0.000 0.000 urllib.py:1053(unwrap)
20 0.000 0.000 0.001 0.000 urllib.py:1062(splittype)
20 0.000 0.000 0.001 0.000 urllib.py:1076(splithost)
20 0.000 0.000 0.001 0.000 urllib.py:1164(splittag)
20 0.000 0.000 0.000 0.000 urllib.py:1201(unquote)
1 0.000 0.000 0.000 0.000 urllib.py:1340(getproxies_environment)
20 0.000 0.000 0.000 0.000 urllib.py:947(__init__)
2 0.000 0.000 0.000 0.000 urllib2.py:1091(__init__)
20 0.000 0.000 0.002 0.000 urllib2.py:1097(do_request_)
20 0.002 0.000 11.716 0.586 urllib2.py:1126(do_open)
20 0.000 0.000 0.000 0.000 urllib2.py:1144(<genexpr>)
80 0.000 0.000 0.000 0.000 urllib2.py:1155(<genexpr>)
20 0.000 0.000 11.717 0.586 urllib2.py:1200(http_open)
20 0.000 0.000 11.726 0.586 urllib2.py:122(urlopen)
20 0.000 0.000 0.002 0.000 urllib2.py:171(request_host)
20 0.000 0.000 0.004 0.000 urllib2.py:189(__init__)
20 0.000 0.000 0.000 0.000 urllib2.py:221(get_method)
40 0.000 0.000 0.000 0.000 urllib2.py:232(has_data)
40 0.000 0.000 0.000 0.000 urllib2.py:238(get_full_url)
40 0.000 0.000 0.001 0.000 urllib2.py:244(get_type)
40 0.000 0.000 0.001 0.000 urllib2.py:251(get_host)
20 0.000 0.000 0.000 0.000 urllib2.py:258(get_selector)
20 0.000 0.000 0.000 0.000 urllib2.py:270(has_proxy)
40 0.000 0.000 0.000 0.000 urllib2.py:283(add_unredirected_header)
40 0.000 0.000 0.000 0.000 urllib2.py:287(has_header)
1 0.000 0.000 0.000 0.000 urllib2.py:302(__init__)
9 0.000 0.000 0.001 0.000 urllib2.py:313(add_handler)
40 0.000 0.000 11.717 0.293 urllib2.py:364(_call_chain)
20 0.001 0.000 11.725 0.586 urllib2.py:376(open)
20 0.000 0.000 11.717 0.586 urllib2.py:404(_open)
1 0.000 0.000 0.001 0.001 urllib2.py:444(build_opener)
8 0.000 0.000 0.000 0.000 urllib2.py:486(add_parent)
13 0.000 0.000 0.000 0.000 urllib2.py:493(__lt__)
20 0.000 0.000 0.000 0.000 urllib2.py:506(http_response)
1 0.000 0.000 0.000 0.000 urllib2.py:704(__init__)
20 0.000 0.000 0.002 0.000 urlparse.py:129(urlparse)
20 0.000 0.000 0.000 0.000 urlparse.py:152(_splitnetloc)
20 0.001 0.000 0.001 0.000 urlparse.py:160(urlsplit)
8 0.000 0.000 0.000 0.000 {_bisect.insort}
20 0.796 0.040 0.796 0.040 {_socket.getaddrinfo}
3 0.000 0.000 0.000 0.000 {_sre.compile}
40 0.000 0.000 0.000 0.000 {built-in method __new__ of type object at 0x84e840}
20 0.000 0.000 0.000 0.000 {built-in method fromkeys}
260 0.000 0.000 0.000 0.000 {cStringIO.StringIO}
9 0.000 0.000 0.000 0.000 {dir}
220 0.000 0.000 0.000 0.000 {getattr}
144 0.000 0.000 0.000 0.000 {hasattr}
89 0.000 0.000 0.000 0.000 {isinstance}
637/632 0.000 0.000 0.000 0.000 {len}
446 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects}
60 0.000 0.000 0.000 0.000 {method 'capitalize' of 'str' objects}
20 5.405 0.270 5.405 0.270 {method 'connect' of '_socket.socket' objects}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
200 0.000 0.000 0.000 0.000 {method 'endswith' of 'str' objects}
20 0.000 0.000 0.000 0.000 {method 'extend' of 'list' objects}
370 0.001 0.000 0.001 0.000 {method 'find' of 'str' objects}
408 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects}
20 0.000 0.000 0.000 0.000 {method 'getvalue' of 'cStringIO.StringO' objects}
60 0.000 0.000 0.000 0.000 {method 'group' of '_sre.SRE_Match' objects}
65 0.000 0.000 0.000 0.000 {method 'items' of 'dict' objects}
20 0.000 0.000 0.000 0.000 {method 'iteritems' of 'dict' objects}
140 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects}
540 0.000 0.000 0.000 0.000 {method 'lower' of 'str' objects}
60 0.000 0.000 0.000 0.000 {method 'match' of '_sre.SRE_Pattern' objects}
200 0.000 0.000 0.000 0.000 {method 'read' of 'cStringIO.StringO' objects}
200 0.000 0.000 0.000 0.000 {method 'readline' of 'cStringIO.StringO' objects}
20 5.491 0.275 5.491 0.275 {method 'recv' of '_socket.socket' objects}
5 0.000 0.000 0.000 0.000 {method 'remove' of 'list' objects}
40 0.000 0.000 0.000 0.000 {method 'rfind' of 'str' objects}
440 0.000 0.000 0.000 0.000 {method 'seek' of 'cStringIO.StringO' objects}
20 0.001 0.000 0.001 0.000 {method 'sendall' of '_socket.socket' objects}
14 0.000 0.000 0.000 0.000 {method 'setdefault' of 'dict' objects}
80 0.000 0.000 0.000 0.000 {method 'split' of 'str' objects}
165 0.000 0.000 0.000 0.000 {method 'startswith' of 'str' objects}
260 0.000 0.000 0.000 0.000 {method 'strip' of 'str' objects}
20 0.000 0.000 0.000 0.000 {method 'sub' of '_sre.SRE_Pattern' objects}
220 0.000 0.000 0.000 0.000 {method 'tell' of 'cStringIO.StringO' objects}
60 0.000 0.000 0.000 0.000 {method 'title' of 'str' objects}
20 0.000 0.000 0.000 0.000 {method 'update' of 'dict' objects}
240 0.001 0.000 0.001 0.000 {method 'write' of 'cStringIO.StringO' objects}
66 0.000 0.000 0.000 0.000 {min}
9 0.000 0.000 0.000 0.000 {ord}
20 0.000 0.000 0.000 0.000 {range}
240 0.000 0.000 0.000 0.000 {setattr}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment