# http://es.stackoverflow.com/q/23328/127
import cProfile, pstats, io
def ne(x):
if x != 'val':
pass
def en(x):
if not x == 'val':
pass
def ee(x):
if x == 'val':
pass
else:
pass
x = 'valor diferente'
pr = cProfile.Profile()
pr.enable()
for i in range(5000000):
ne(x)
en(x)
ee(x)
pr.disable()
s = io.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
print(s.getvalue())
IyBodHRwOi8vZXMuc3RhY2tvdmVyZmxvdy5jb20vcS8yMzMyOC8xMjcKaW1wb3J0IGNQcm9maWxlLCBwc3RhdHMsIGlvCgpkZWYgbmUoeCk6CiAgICBpZiB4ICE9ICd2YWwnOgogICAgICAgIHBhc3MKCmRlZiBlbih4KToKICAgIGlmIG5vdCB4ID09ICd2YWwnOgogICAgICAgIHBhc3MKCmRlZiBlZSh4KToKICAgIGlmIHggPT0gJ3ZhbCc6CiAgICAgICAgcGFzcwogICAgZWxzZToKICAgICAgICBwYXNzCgoKeCA9ICd2YWxvciBkaWZlcmVudGUnCnByID0gY1Byb2ZpbGUuUHJvZmlsZSgpCnByLmVuYWJsZSgpCmZvciBpIGluIHJhbmdlKDUwMDAwMDApOgoJbmUoeCkKCWVuKHgpCgllZSh4KQpwci5kaXNhYmxlKCkKcyA9IGlvLlN0cmluZ0lPKCkKc29ydGJ5ID0gJ2N1bXVsYXRpdmUnCnBzID0gcHN0YXRzLlN0YXRzKHByLCBzdHJlYW09cykuc29ydF9zdGF0cyhzb3J0YnkpCnBzLnByaW50X3N0YXRzKCkKcHJpbnQocy5nZXR2YWx1ZSgpKQ==