Author: Matti Picus <matti.pi...@gmail.com> Branch: py3 Changeset: r394:c3f1a4a9b2b3 Date: 2020-01-01 07:52 +0200 http://bitbucket.org/pypy/benchmarks/changeset/c3f1a4a9b2b3/
Log: benchmark runner fixes for python3/newer versions diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -1,3 +1,4 @@ .*\.py[co] .*~ lib/cpython-doc/tools/build +.*.swp diff --git a/own/bm_chameleon.py b/own/bm_chameleon.py --- a/own/bm_chameleon.py +++ b/own/bm_chameleon.py @@ -1,5 +1,10 @@ from chameleon import PageTemplate +import sys +if sys.version_info[0] < 3: + strstr = 'unicode' +else: + strstr = 'str' BIGTABLE_ZPT = """\ <table xmlns="http://www.w3.org/1999/xhtml" @@ -7,11 +12,11 @@ <tr tal:repeat="row python: options['table']"> <td tal:repeat="c python: row.values()"> <span tal:define="d python: c + 1" -tal:attributes="class python: 'column-' + unicode(d)" +tal:attributes="class python: 'column-' + %s(d)" tal:content="python: d" /> </td> </tr> -</table>""" +</table>""" % strstr def main(n): tmpl = PageTemplate(BIGTABLE_ZPT) diff --git a/own/bm_dulwich_log.py b/own/bm_dulwich_log.py --- a/own/bm_dulwich_log.py +++ b/own/bm_dulwich_log.py @@ -10,7 +10,7 @@ import time for i in range(20): t0 = time.time() - r.revision_history(r.head()) + [e.commit for e in r.get_walker(r.head())] l.append(time.time() - t0) return l diff --git a/own/bm_mako.py b/own/bm_mako.py --- a/own/bm_mako.py +++ b/own/bm_mako.py @@ -17,6 +17,12 @@ import optparse import time +if sys.version_info[0] < 3: + rangestr = 'xrange' +else: + xrange = range + rangestr = 'range' + # Local imports import util @@ -64,25 +70,25 @@ """ PAGE_TEMPLATE = """ -<%inherit file="base.mako"/> +<%%inherit file="base.mako"/> <table> - % for row in table: + %% for row in table: <tr> - % for col in row: + %% for col in row: <td>${col}</td> - % endfor + %% endfor </tr> - % endfor + %% endfor </table> -% for nr in xrange(img_count): +%% for nr in %s(img_count): ${parent.img('/foo/bar/baz.png', 'no image :o')} -% endfor +%% endfor ${next.body()} -% for nr in paragraphs: +%% for nr in paragraphs: <p>${lorem|x}</p> -% endfor +%% endfor ${parent.render_table(table)} -""" +""" % rangestr CONTENT_TEMPLATE = """ <%inherit file="page.mako"/> diff --git a/own/util.py b/own/util.py --- a/own/util.py +++ b/own/util.py @@ -2,4 +2,5 @@ root = os.path.abspath(os.path.join(__file__, '..', '..')) util_py = os.path.join(root, 'unladen_swallow', 'performance', 'util.py') -execfile(util_py) +with open(util_py) as fid: + exec(fid.read()) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit