summaryrefslogtreecommitdiff
path: root/tests/perf_bench/misc_pystone.py
diff options
context:
space:
mode:
authorDavid Lechner <david@lechnology.com>2020-03-22 21:26:08 -0500
committerDamien George <damien.p.george@gmail.com>2020-03-30 13:21:58 +1100
commit3dc324d3f1312e40d3a8ed87e7244966bb756f26 (patch)
tree94ff44f8eabba0039582c245b901173597edd11e /tests/perf_bench/misc_pystone.py
parent488613bca6c460340ed2995ae5cafafe22d0bfff (diff)
tests: Format all Python code with black, except tests in basics subdir.
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
Diffstat (limited to 'tests/perf_bench/misc_pystone.py')
-rw-r--r--tests/perf_bench/misc_pystone.py66
1 files changed, 40 insertions, 26 deletions
diff --git a/tests/perf_bench/misc_pystone.py b/tests/perf_bench/misc_pystone.py
index 88626774b..26f91c7be 100644
--- a/tests/perf_bench/misc_pystone.py
+++ b/tests/perf_bench/misc_pystone.py
@@ -16,10 +16,9 @@ __version__ = "1.2"
[Ident1, Ident2, Ident3, Ident4, Ident5] = range(1, 6)
-class Record:
- def __init__(self, PtrComp = None, Discr = 0, EnumComp = 0,
- IntComp = 0, StringComp = 0):
+class Record:
+ def __init__(self, PtrComp=None, Discr=0, EnumComp=0, IntComp=0, StringComp=0):
self.PtrComp = PtrComp
self.Discr = Discr
self.EnumComp = EnumComp
@@ -27,12 +26,13 @@ class Record:
self.StringComp = StringComp
def copy(self):
- return Record(self.PtrComp, self.Discr, self.EnumComp,
- self.IntComp, self.StringComp)
+ return Record(self.PtrComp, self.Discr, self.EnumComp, self.IntComp, self.StringComp)
+
TRUE = 1
FALSE = 0
+
def Setup():
global IntGlob
global BoolGlob
@@ -43,10 +43,11 @@ def Setup():
IntGlob = 0
BoolGlob = FALSE
- Char1Glob = '\0'
- Char2Glob = '\0'
- Array1Glob = [0]*51
- Array2Glob = [x[:] for x in [Array1Glob]*51]
+ Char1Glob = "\0"
+ Char2Glob = "\0"
+ Array1Glob = [0] * 51
+ Array2Glob = [x[:] for x in [Array1Glob] * 51]
+
def Proc0(loops):
global IntGlob
@@ -82,16 +83,17 @@ def Proc0(loops):
IntLoc1 = IntLoc1 + 1
Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3)
PtrGlb = Proc1(PtrGlb)
- CharIndex = 'A'
+ CharIndex = "A"
while CharIndex <= Char2Glob:
- if EnumLoc == Func1(CharIndex, 'C'):
+ if EnumLoc == Func1(CharIndex, "C"):
EnumLoc = Proc6(Ident1)
- CharIndex = chr(ord(CharIndex)+1)
+ CharIndex = chr(ord(CharIndex) + 1)
IntLoc3 = IntLoc2 * IntLoc1
IntLoc2 = IntLoc3 // IntLoc1
IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1
IntLoc1 = Proc2(IntLoc1)
+
def Proc1(PtrParIn):
PtrParIn.PtrComp = NextRecord = PtrGlb.copy()
PtrParIn.IntComp = 5
@@ -108,10 +110,11 @@ def Proc1(PtrParIn):
NextRecord.PtrComp = None
return PtrParIn
+
def Proc2(IntParIO):
IntLoc = IntParIO + 10
while 1:
- if Char1Glob == 'A':
+ if Char1Glob == "A":
IntLoc = IntLoc - 1
IntParIO = IntLoc - IntGlob
EnumLoc = Ident1
@@ -119,6 +122,7 @@ def Proc2(IntParIO):
break
return IntParIO
+
def Proc3(PtrParOut):
global IntGlob
@@ -129,20 +133,23 @@ def Proc3(PtrParOut):
PtrGlb.IntComp = Proc7(10, IntGlob)
return PtrParOut
+
def Proc4():
global Char2Glob
- BoolLoc = Char1Glob == 'A'
+ BoolLoc = Char1Glob == "A"
BoolLoc = BoolLoc or BoolGlob
- Char2Glob = 'B'
+ Char2Glob = "B"
+
def Proc5():
global Char1Glob
global BoolGlob
- Char1Glob = 'A'
+ Char1Glob = "A"
BoolGlob = FALSE
+
def Proc6(EnumParIn):
EnumParOut = EnumParIn
if not Func3(EnumParIn):
@@ -162,24 +169,27 @@ def Proc6(EnumParIn):
EnumParOut = Ident3
return EnumParOut
+
def Proc7(IntParI1, IntParI2):
IntLoc = IntParI1 + 2
IntParOut = IntParI2 + IntLoc
return IntParOut
+
def Proc8(Array1Par, Array2Par, IntParI1, IntParI2):
global IntGlob
IntLoc = IntParI1 + 5
Array1Par[IntLoc] = IntParI2
- Array1Par[IntLoc+1] = Array1Par[IntLoc]
- Array1Par[IntLoc+30] = IntLoc
- for IntIndex in range(IntLoc, IntLoc+2):
+ Array1Par[IntLoc + 1] = Array1Par[IntLoc]
+ Array1Par[IntLoc + 30] = 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][IntLoc - 1] = Array2Par[IntLoc][IntLoc - 1] + 1
+ Array2Par[IntLoc + 20][IntLoc] = Array1Par[IntLoc]
IntGlob = 5
+
def Func1(CharPar1, CharPar2):
CharLoc1 = CharPar1
CharLoc2 = CharLoc1
@@ -188,15 +198,16 @@ def Func1(CharPar1, CharPar2):
else:
return Ident2
+
def Func2(StrParI1, StrParI2):
IntLoc = 1
while IntLoc <= 1:
- if Func1(StrParI1[IntLoc], StrParI2[IntLoc+1]) == Ident1:
- CharLoc = 'A'
+ if Func1(StrParI1[IntLoc], StrParI2[IntLoc + 1]) == Ident1:
+ CharLoc = "A"
IntLoc = IntLoc + 1
- if CharLoc >= 'W' and CharLoc <= 'Z':
+ if CharLoc >= "W" and CharLoc <= "Z":
IntLoc = 7
- if CharLoc == 'X':
+ if CharLoc == "X":
return TRUE
else:
if StrParI1 > StrParI2:
@@ -205,9 +216,11 @@ def Func2(StrParI1, StrParI2):
else:
return FALSE
+
def Func3(EnumParIn):
EnumLoc = EnumParIn
- if EnumLoc == Ident3: return TRUE
+ if EnumLoc == Ident3:
+ return TRUE
return FALSE
@@ -221,6 +234,7 @@ bm_params = {
(5000, 10): (20000,),
}
+
def bm_setup(params):
Setup()
return lambda: Proc0(params[0]), lambda: (params[0], 0)