Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f849f46

Browse files
committed
(Merge 3.4) Issue #21634: Fix pystone micro-benchmark: use floor division
instead of true division to benchmark integers instead of floating point numbers. Set pystone version to 1.2. Patch written by Lennart Regebro.
2 parents 5a1bb4e + d4d39c7 commit f849f46

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

Lib/test/pystone.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
"PYSTONE" Benchmark Program
55
6-
Version: Python/1.1 (corresponds to C/1.1 plus 2 Pystone fixes)
6+
Version: Python/1.2 (corresponds to C/1.1 plus 3 Pystone fixes)
77
88
Author: Reinhold P. Weicker, CACM Vol 27, No 10, 10/84 pg. 1013.
99
@@ -30,13 +30,20 @@
3030
percent faster than version 1.0, so benchmark figures
3131
of different versions can't be compared directly.
3232
33+
Version 1.2 changes the division to floor division.
34+
35+
Under Python 3 version 1.1 would use the normal division
36+
operator, resulting in some of the operations mistakenly
37+
yielding floats. Version 1.2 instead uses floor division
38+
making the benchmark a integer benchmark again.
39+
3340
"""
3441

3542
LOOPS = 50000
3643

3744
from time import clock
3845

39-
__version__ = "1.1"
46+
__version__ = "1.2"
4047

4148
[Ident1, Ident2, Ident3, Ident4, Ident5] = range(1, 6)
4249

@@ -123,7 +130,7 @@ def Proc0(loops=LOOPS):
123130
EnumLoc = Proc6(Ident1)
124131
CharIndex = chr(ord(CharIndex)+1)
125132
IntLoc3 = IntLoc2 * IntLoc1
126-
IntLoc2 = IntLoc3 / IntLoc1
133+
IntLoc2 = IntLoc3 // IntLoc1
127134
IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1
128135
IntLoc1 = Proc2(IntLoc1)
129136

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,10 @@ Documentation
532532
Tests
533533
-----
534534

535+
- Issue #21634: Fix pystone micro-benchmark: use floor division instead of true
536+
division to benchmark integers instead of floating point numbers. Set pystone
537+
version to 1.2. Patch written by Lennart Regebro.
538+
535539
- Issue #21605: Added tests for Tkinter images.
536540

537541
- Issue #21493: Added test for ntpath.expanduser(). Original patch by

0 commit comments

Comments
 (0)