[pypy-commit] pypy pyparser-improvements-2: make it possible to pass diferent files to the parsing target
cfbolz
pypy.commits at gmail.com
Sun Apr 8 06:18:13 EDT 2018
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: pyparser-improvements-2
Changeset: r94269:0066fc716a62
Date: 2018-04-02 07:53 +0200
http://bitbucket.org/pypy/pypy/changeset/0066fc716a62/
Log: make it possible to pass diferent files to the parsing target
diff --git a/pypy/interpreter/pyparser/test/targetparse.py b/pypy/interpreter/pyparser/test/targetparse.py
--- a/pypy/interpreter/pyparser/test/targetparse.py
+++ b/pypy/interpreter/pyparser/test/targetparse.py
@@ -8,25 +8,36 @@
-with file("../../../rpython/rlib/unicodedata/unicodedb_5_2_0.py") as f:
- s = f.read()
-
class FakeSpace(object):
pass
fakespace = FakeSpace()
-def bench(title):
+def bench(fn, s):
a = time.clock()
info = pyparse.CompileInfo("<string>", "exec")
parser = pyparse.PythonParser(fakespace)
tree = parser._parse(s, info)
b = time.clock()
- print title, (b-a)
+ print fn, (b-a)
def entry_point(argv):
- bench("foo")
+ if len(argv) == 2:
+ fn = argv[1]
+ else:
+ fn = "../../../../rpython/rlib/unicodedata/unicodedb_5_2_0.py"
+ fd = os.open(fn, os.O_RDONLY, 0777)
+ res = []
+ while True:
+ s = os.read(fd, 4096)
+ if not s:
+ break
+ res.append(s)
+ os.close(fd)
+ s = "".join(res)
+ print len(s)
+ bench(fn, s)
return 0
More information about the pypy-commit
mailing list