Skip to content

Commit 102edfe

Browse files
committed
[GR-15801] Size micro+meso benchmarks to run at least ~1s per iter + enable remaining meso benchmarks
PullRequest: graalpython/874
2 parents 0b14840 + 71f8a71 commit 102edfe

26 files changed

+83443
-107
lines changed

graalpython/com.oracle.graal.python.benchmarks/python/meso/knucleotide-input.txt

Lines changed: 83337 additions & 0 deletions
Large diffs are not rendered by default.

graalpython/com.oracle.graal.python.benchmarks/python/meso/knucleotide.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@
4545
# modified by Justin Peel
4646

4747
from collections import defaultdict
48+
import os
4849

4950

5051
def gen_freq(seq, frame, frequencies):
5152
if frame != 1:
5253
ns = len(seq) + 1 - frame
5354
frequencies.clear()
54-
for ii in xrange(ns):
55+
for ii in range(ns):
5556
frequencies[seq[ii:ii + frame]] += 1
5657
return ns, frequencies
5758
for nucleo in seq:
@@ -62,30 +63,30 @@ def gen_freq(seq, frame, frequencies):
6263
def sort_seq(seq, length, frequencies):
6364
n, frequencies = gen_freq(seq, length, frequencies)
6465

65-
l = sorted(frequencies.items(), reverse=True, key=lambda (seq,freq): (freq,seq))
66+
l = sorted(list(frequencies.items()), reverse=True, key=lambda item: item)
6667

67-
print '\n'.join("%s %.3f" % (st, 100.0*fr/n) for st,fr in l)
68-
print
68+
print('\n'.join("%s %.3f" % (st, 100.0*fr/n) for st,fr in l))
6969

7070

7171
def find_seq(seq, s, frequencies):
7272
n,t = gen_freq(seq, len(s), frequencies)
73-
print "%d\t%s" % (t.get(s, 0), s)
73+
print("%d\t%s" % (t.get(s, 0), s))
7474

7575

76-
def main(stdin):
76+
def main():
7777
frequencies = defaultdict(int)
78-
for line in stdin:
79-
if line[0] == ">":
80-
if line[1:3] == "TH":
78+
with open(os.path.join(os.path.dirname(__file__), "knucleotide-input.txt")) as f:
79+
for line in f:
80+
if line[0] == ">":
81+
if line[1:3] == "TH":
82+
break
83+
84+
seq = []
85+
seq_append = seq.append
86+
for line in f:
87+
if line[0] in ">;":
8188
break
82-
83-
seq = []
84-
seq_append = seq.append
85-
for line in stdin:
86-
if line[0] in ">;":
87-
break
88-
seq_append(line)
89+
seq_append(line)
8990
sequence = "".join(seq).replace('\n','').upper()
9091

9192
for nl in 1,2:
@@ -96,5 +97,4 @@ def main(stdin):
9697

9798

9899
def __benchmark__(*args):
99-
# main() # provide proper input
100-
pass
100+
main()

graalpython/com.oracle.graal.python.benchmarks/python/meso/regexdna.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
def main(seq):
4848
ilen = len(seq)
4949

50-
seq = sub('>.*\n|\n', '', seq)
50+
seq = sub('>.*\n|\n', '', seq)
5151
clen = len(seq)
5252

5353
variants = (
@@ -61,13 +61,13 @@ def main(seq):
6161
'agggta[cgt]a|t[acg]taccct',
6262
'agggtaa[cgt]|[acg]ttaccct')
6363
for f in variants:
64-
print f, sum(1 for i in finditer(f, seq))
64+
print(f, sum(1 for i in finditer(f, seq)))
6565

6666
subst = {
6767
'B' : '(c|g|t)', 'D' : '(a|g|t)', 'H' : '(a|c|t)', 'K' : '(g|t)',
6868
'M' : '(a|c)', 'N' : '(a|c|g|t)', 'R' : '(a|g)', 'S' : '(c|g)',
6969
'V' : '(a|c|g)', 'W' : '(a|t)', 'Y' : '(c|t)'}
70-
for f, r in subst.items():
70+
for f, r in list(subst.items()):
7171
seq = sub(f, r, seq)
7272

7373
print(ilen)
@@ -76,5 +76,7 @@ def main(seq):
7676

7777

7878
def __benchmark__(*args):
79-
# main(seq) # TODO provide proper input
80-
pass
79+
import os
80+
with open(os.path.join(os.path.dirname(__file__), "knucleotide-input.txt")) as f:
81+
seq = f.read()
82+
main(seq)

graalpython/com.oracle.graal.python.benchmarks/python/meso/threadring.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,18 @@
4848

4949

5050
def main(n, n_threads=503, cycle=itertools.cycle):
51-
5251
def worker(worker_id):
5352
n = 1
5453
while True:
55-
print(n)
5654
if n > 0:
5755
n = (yield (n - 1))
5856
else:
5957
print(worker_id)
60-
raise StopIteration
58+
return
6159

6260

6361
threadRing = [worker(w) for w in range(1, n_threads + 1)]
64-
for t in threadRing: foo = t.next() # start exec. gen. funcs
62+
for t in threadRing: foo = next(t) # start exec. gen. funcs
6563
sendFuncRing = [t.send for t in threadRing] # speed...
6664
for send in cycle(sendFuncRing):
6765
try:
@@ -70,5 +68,5 @@ def worker(worker_id):
7068
break
7169

7270

73-
def __bnenchmark__(num=100):
71+
def __benchmark__(num=100):
7472
main(num)

graalpython/com.oracle.graal.python.benchmarks/python/micro/arith-modulo.py renamed to graalpython/com.oracle.graal.python.benchmarks/python/micro/arith-modulo-sized.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ def measure(num):
4848

4949

5050
def __benchmark__(num=50):
51-
measure(50)
51+
measure(num)

graalpython/com.oracle.graal.python.benchmarks/python/micro/boolean-logic.py renamed to graalpython/com.oracle.graal.python.benchmarks/python/micro/boolean-logic-sized.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def no_object_do_stuff():
8484

8585

8686
def measure(num):
87-
for i in range(num): # 50000
87+
for i in range(num):
8888
result = do_stuff()
8989

9090
print(result)

graalpython/com.oracle.graal.python.benchmarks/python/micro/builtin-len-tuple.py renamed to graalpython/com.oracle.graal.python.benchmarks/python/micro/builtin-len-tuple-sized.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ def call_len(num, ll):
3131
return length
3232

3333

34-
def measure():
34+
def measure(num):
3535
ll = tuple(range(1000))
36-
length = call_len(1000000000, ll) # 1000000
36+
length = call_len(num, ll)
3737

3838
print("Final length ", length)
3939

4040

41-
def __benchmark__(*args):
42-
measure()
41+
def __benchmark__(num):
42+
measure(num)

0 commit comments

Comments
 (0)