~jendrikseipp/pogo/github-mirror

« back to all changes in this revision

Viewing changes to benchmarks/sum.py

  • Committer: GitHub
  • Author(s): Jendrik Seipp
  • Date: 2017-07-16 15:22:48 UTC
  • mfrom: (695.1.4)
  • Revision ID: git-v1:08a9790f5259c0afc6beb390a10358e104e209c9
Merge pull request #42 from jendrikseipp/pep8

Fix code style (PEP8)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
import timeit
4
4
 
5
 
LIST     = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [12, 14], [15, 16], [17, 18], [19, 20]]
 
5
LIST = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [12, 14], [15, 16], [17, 18], [19, 20]]
6
6
NB_ITERS = 500000
7
7
 
8
8
# ---
9
9
 
 
10
 
10
11
def withLoop():
11
12
    s = 0
12
13
    for value in LIST:
15
16
 
16
17
# ---
17
18
 
 
19
 
18
20
def withSum():
19
21
    return sum([value[1] for value in LIST])
20
22
 
21
23
# ---
22
24
 
 
25
 
23
26
t1 = timeit.Timer('withLoop()', 'from __main__ import withLoop')
24
 
t2 = timeit.Timer('withSum()',  'from __main__ import withSum')
 
27
t2 = timeit.Timer('withSum()', 'from __main__ import withSum')
25
28
 
26
29
 
27
30
print