# http://es.stackoverflow.com/q/23328/127
import cProfile, pstats, io, string
from random import randint, choice
semilla = 'valor'
val = semilla + ' a comparar'
def ne(x):
if x != val:
pass
def en(x):
if not x == val:
pass
def ee(x):
if x == val:
pass
else:
pass
def rndx():
if ( randint(0,1)==0 ):
return val
else:
return semilla + ''.join(choice(val) for i in range(randint(1,20)))
x = val
pr = cProfile.Profile()
pr.enable()
for i in range(2000000):
if (i % 10000 == 0):
x = rndx()
en(x)
ee(x)
ne(x)
pr.disable()
s = io.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
print(s.getvalue())
IyBodHRwOi8vZXMuc3RhY2tvdmVyZmxvdy5jb20vcS8yMzMyOC8xMjcKaW1wb3J0IGNQcm9maWxlLCBwc3RhdHMsIGlvLCBzdHJpbmcKZnJvbSByYW5kb20gaW1wb3J0IHJhbmRpbnQsIGNob2ljZQoKc2VtaWxsYSA9ICd2YWxvcicKdmFsID0gc2VtaWxsYSArICcgYSBjb21wYXJhcicKCmRlZiBuZSh4KToKICAgIGlmIHggIT0gdmFsOgogICAgICAgIHBhc3MKCmRlZiBlbih4KToKICAgIGlmIG5vdCB4ID09IHZhbDoKICAgICAgICBwYXNzCgpkZWYgZWUoeCk6CiAgICBpZiB4ID09IHZhbDoKICAgICAgICBwYXNzCiAgICBlbHNlOgogICAgICAgIHBhc3MKICAgICAgICAKZGVmIHJuZHgoKToKCWlmICggcmFuZGludCgwLDEpPT0wICk6CgkJcmV0dXJuIHZhbAoJZWxzZToKCQlyZXR1cm4gc2VtaWxsYSArICcnLmpvaW4oY2hvaWNlKHZhbCkgZm9yIGkgaW4gcmFuZ2UocmFuZGludCgxLDIwKSkpCiAKCnggPSB2YWwKcHIgPSBjUHJvZmlsZS5Qcm9maWxlKCkKcHIuZW5hYmxlKCkKZm9yIGkgaW4gcmFuZ2UoMjAwMDAwMCk6CglpZiAoaSAlIDEwMDAwID09IDApOgoJCXggPSBybmR4KCkKCWVuKHgpCgllZSh4KQoJbmUoeCkKcHIuZGlzYWJsZSgpCnMgPSBpby5TdHJpbmdJTygpCnNvcnRieSA9ICdjdW11bGF0aXZlJwpwcyA9IHBzdGF0cy5TdGF0cyhwciwgc3RyZWFtPXMpLnNvcnRfc3RhdHMoc29ydGJ5KQpwcy5wcmludF9zdGF0cygpCnByaW50KHMuZ2V0dmFsdWUoKSk=