mirror of
https://github.com/python/cpython.git
synced 2025-11-13 15:40:05 +00:00
Issue #4677: add two list comprehension tests to pybench.
This commit is contained in:
parent
1ffbfbc566
commit
e555f581dc
2 changed files with 60 additions and 0 deletions
|
|
@ -190,6 +190,11 @@ Library
|
||||||
- Issue #4730: Fixed the cPickle module to handle correctly astral characters
|
- Issue #4730: Fixed the cPickle module to handle correctly astral characters
|
||||||
when protocol 0 is used.
|
when protocol 0 is used.
|
||||||
|
|
||||||
|
Tools/Demos
|
||||||
|
-----------
|
||||||
|
|
||||||
|
- Issue #4677: add two list comprehension tests to pybench.
|
||||||
|
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -293,3 +293,58 @@ class SmallLists(Test):
|
||||||
|
|
||||||
for i in xrange(self.rounds):
|
for i in xrange(self.rounds):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class SimpleListComprehensions(Test):
|
||||||
|
|
||||||
|
version = 2.0
|
||||||
|
operations = 6
|
||||||
|
rounds = 20000
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
|
||||||
|
n = range(10) * 10
|
||||||
|
|
||||||
|
for i in xrange(self.rounds):
|
||||||
|
l = [x for x in n]
|
||||||
|
l = [x for x in n if x]
|
||||||
|
l = [x for x in n if not x]
|
||||||
|
|
||||||
|
l = [x for x in n]
|
||||||
|
l = [x for x in n if x]
|
||||||
|
l = [x for x in n if not x]
|
||||||
|
|
||||||
|
def calibrate(self):
|
||||||
|
|
||||||
|
n = range(10) * 10
|
||||||
|
|
||||||
|
for i in xrange(self.rounds):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class NestedListComprehensions(Test):
|
||||||
|
|
||||||
|
version = 2.0
|
||||||
|
operations = 6
|
||||||
|
rounds = 20000
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
|
||||||
|
m = range(10)
|
||||||
|
n = range(10)
|
||||||
|
|
||||||
|
for i in xrange(self.rounds):
|
||||||
|
l = [x for x in n for y in m]
|
||||||
|
l = [y for x in n for y in m]
|
||||||
|
|
||||||
|
l = [x for x in n for y in m if y]
|
||||||
|
l = [y for x in n for y in m if x]
|
||||||
|
|
||||||
|
l = [x for x in n for y in m if not y]
|
||||||
|
l = [y for x in n for y in m if not x]
|
||||||
|
|
||||||
|
def calibrate(self):
|
||||||
|
|
||||||
|
m = range(10)
|
||||||
|
n = range(10)
|
||||||
|
|
||||||
|
for i in xrange(self.rounds):
|
||||||
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue