Commit 6a6dc30e authored by Kevin Modzelewski's avatar Kevin Modzelewski Committed by Kevin Modzelewski

Misc tools+microbenchmarks

parent 8ceb2254
......@@ -43,3 +43,15 @@ for i in xrange(1000):
# if not n:
# break
# sre_parse.parse(pattern, 0)
class C:
pass
c = C()
c.a = 1
def f(c):
n = 10000000
while n:
c.a
f(c)
def f():
i = 0
n = 10000000
s1 = ""
s2 = ""
while i < n:
i = i + 1
s1 < s2
s1 <= s2
s1 > s2
s1 >= s2
s1 == s2
s1 != s2
f()
import argparse
import os
import subprocess
import sys
import time
if __name__ == "__main__":
cmd = ["./pyston_release", "-Ts", sys.argv[1]]
start = time.time()
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, err = p.communicate()
assert p.wait() == 0
elapsed = time.time() - start
open('tmp.txt', 'w').write(out)
# elapsed = 1.5
# out = open("tmp.txt").read()
stats = []
is_counter = False
for l in out.split('\n'):
if l.strip() == "Counters:":
is_counter = True
continue
if l.strip() == "(End of stats)":
is_counter = False
continue
if not is_counter:
continue
name, count = l.split(':')
count = int(count)
if name.startswith('us_timer'):
stats.append((name, 0.000001 * count))
# if name.startswith('slowpath'):
# stats.append((name, 0.0000001 * count))
stats.sort(key=lambda (name,s): s, reverse=True)
print "Most interesting stats:"
for (name, s) in stats[:10]:
print "% 40s %.3fs (%.0f%%)" % (name, s, 100.0 * s / elapsed)
print "%.1fs total time" % elapsed
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment