bpo-35884: Add missing FIFO queue benchmark (GH-11898)

https://bugs.python.org/issue35884
This commit is contained in:
Raymond Hettinger 2019-02-16 12:51:02 -08:00 committed by Miss Islington (bot)
parent e182318e6a
commit 43766f82dd
1 changed files with 10 additions and 1 deletions

View File

@ -214,6 +214,15 @@ def deque_append_pop(trials=trials, a=deque([1])):
ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop();
ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop();
def deque_append_popleft(trials=trials, a=deque([1])):
ap, pop = a.append, a.popleft
for t in trials:
ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop();
ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop();
ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop();
ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop();
ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop(); ap(1); pop();
def write_list(trials=trials, a=[1]):
for t in trials:
a[0]=1; a[0]=1; a[0]=1; a[0]=1; a[0]=1
@ -261,7 +270,7 @@ if __name__=='__main__':
'\nData structure write access:',
write_list, write_deque, write_dict,
'\nStack (or queue) operations:',
list_append_pop, deque_append_pop,
list_append_pop, deque_append_pop, deque_append_popleft,
'\nTiming loop overhead:',
loop_overhead]:
if isinstance(f, str):