(0, 0, "def f(x): return x\nlist(f(x) for x in 'spam' * 2500)"), # set and dicts # (0, 0, "{x ** 2 for x in range(1000)}"), # (0, 0, "s=set()\nfor x in range(1000): s.add(x ** 2)"), # (0, 0, "{x: x ** 2 for x in range(1000)}"), # (0, 0, "d={}\nfor x in range(1000): d[x] = x ** 2"), # more string tests # (0, 0, "s = 'spam' * 2500\nx = [s[i] for i in range(10000)]"), # (0, 0, "s = '?'\nfor i in range(10000): s += '?'"), # Iterations: for -a \t replaced with 4*' ', may fail some shells? # (0, 0, "L = [1, 2, 3, 4, 5]\nfor i in range(len(L)): L[i] += 1"), # (0, 0, "L = [1, 2, 3, 4, 5]\ni=0\nwhile i < len(L):\n\tL[i] += 1\n\ti += 1"), # (0, 0, "L = [1, 2, 3, 4, 5]\nM = [x + 1 for x in L]"), # Files: close() else may fail in pypy due to number of open files # (0, 0, "f=open('C:/Python33/Lib/pdb.py')\nfor line in f: x=line\nf.close()"), # (0, 0, "f=open('C:/Python33/Lib/pdb.py')\nfor line in f.readlines(): x=line\nf.close()"), # (0, 0, "f = open('C:/Python33/Lib/pdb.py')\n" # "while True:\n\tline = f.readline()\n\tif not line: break\n\tx = line\nf.close()") # pathological: 300k digits (1, 1, "len(str(2**1000000))") # pypy loses on this today ] tracecmd = '-t' in sys.argv # -t: trace commmand lines? pythons = pythons if '-a' in sys.argv else None # -a: all in list, else one? pybench.runner(stmts, pythons, tracecmd)
(0, 0, "{x: x ** 2 for x in range(1000)}"), (0, 0, "d={}\nfor x in range(1000): d[x] = x ** 2"), # more string tests (0, 0, "s = 'spam' * 2500\nx = [s[i] for i in range(10000)]"), (0, 0, "s = '?'\nfor i in range(10000): s += '?'"), # Iterations: for -a \t replaced with 4*' ', may fail some shells? (0, 0, "L = [1, 2, 3, 4, 5]\nfor i in range(len(L)): L[i] += 1"), (0, 0, "L = [1, 2, 3, 4, 5]\ni=0\nwhile i < len(L):\n\tL[i] += 1\n\ti += 1"), (0, 0, "L = [1, 2, 3, 4, 5]\nM = [x + 1 for x in L]"), # Files: close() else may fail in pypy due to number of open files (0, 0, "f=open('C:/Python33/Lib/pdb.py')\nfor line in f: x=line\nf.close()" ), (0, 0, "f=open('C:/Python33/Lib/pdb.py')\nfor line in f.readlines(): x=line\nf.close()" ), (0, 0, "f = open('C:/Python33/Lib/pdb.py')\n" "while True:\n\tline = f.readline()\n\tif not line: break\n\tx = line\nf.close()" ), # pathological: 300k digits (1, 1, "len(str(2**1000000))") # pypy loses on this today ] tracecmd = '-t' in sys.argv # -t: trace commmand lines? pythons = pythons if '-a' in sys.argv else None # -a: all in list, else one? pybench.runner(stmts, pythons, tracecmd)