From f6937ebb47919ccc3dc5983353d0175200e8334d Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 15 Feb 2016 12:17:21 +0200 Subject: [PATCH] pystone_lowmem: Work arrays of size 25 instead of 51. There're 2 arrays - one dimensional of 25 elements, and 2-dimensional of 25x25 elements. Number of iterations stays the same, it's just consecutive iterations may access the same array elements. So, while the result of calculations may differ, the timing should stay about the same (well, lowmem version will be a bit slower, as array index division by 2 is used in several places). --- pystone_lowmem/pystone_lowmem.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pystone_lowmem/pystone_lowmem.py b/pystone_lowmem/pystone_lowmem.py index 2280c536..a7dbc545 100755 --- a/pystone_lowmem/pystone_lowmem.py +++ b/pystone_lowmem/pystone_lowmem.py @@ -78,8 +78,8 @@ IntGlob = 0 BoolGlob = FALSE Char1Glob = '\0' Char2Glob = '\0' -Array1Glob = [0]*51 -Array2Glob = [x[:] for x in [Array1Glob]*51] +Array1Glob = [0]*(51 // 2) +Array2Glob = [x[:] for x in [Array1Glob]*(51 // 2)] PtrGlb = None PtrGlbNext = None @@ -106,7 +106,7 @@ def Proc0(loops=LOOPS): PtrGlb.IntComp = 40 PtrGlb.StringComp = "DHRYSTONE PROGRAM, SOME STRING" String1Loc = "DHRYSTONE PROGRAM, 1'ST STRING" - Array2Glob[8][7] = 10 + Array2Glob[8 // 2][7 // 2] = 10 starttime = clock() @@ -220,13 +220,13 @@ def Proc8(Array1Par, Array2Par, IntParI1, IntParI2): global IntGlob IntLoc = IntParI1 + 5 - Array1Par[IntLoc] = IntParI2 - Array1Par[IntLoc+1] = Array1Par[IntLoc] - Array1Par[IntLoc+30] = IntLoc + Array1Par[IntLoc // 2] = IntParI2 + Array1Par[(IntLoc+1) // 2] = Array1Par[IntLoc // 2] + Array1Par[(IntLoc+30) // 2] = IntLoc for IntIndex in range(IntLoc, IntLoc+2): - Array2Par[IntLoc][IntIndex] = IntLoc - Array2Par[IntLoc][IntLoc-1] = Array2Par[IntLoc][IntLoc-1] + 1 - Array2Par[IntLoc+20][IntLoc] = Array1Par[IntLoc] + Array2Par[IntLoc // 2][IntIndex // 2] = IntLoc + Array2Par[IntLoc // 2][(IntLoc-1) // 2] = Array2Par[IntLoc // 2][(IntLoc-1) // 2] + 1 + Array2Par[(IntLoc+20) // 2][IntLoc // 2] = Array1Par[IntLoc // 2] IntGlob = 5 def Func1(CharPar1, CharPar2):