From 74c5ec56614be39b64f6f65951be479002471add Mon Sep 17 00:00:00 2001 From: derzhavin3016 Date: Wed, 5 Apr 2023 00:11:01 +0300 Subject: [PATCH] Add bench example --- test/gc/bench.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/gc/bench.py diff --git a/test/gc/bench.py b/test/gc/bench.py new file mode 100644 index 0000000..7011b13 --- /dev/null +++ b/test/gc/bench.py @@ -0,0 +1,35 @@ +class Bar: + def __init__(self, a): + self.a = a + +class Foo: + def __init__(self, x): + self.x = x + self.y = None + + def setY(self, b): + self.y = b + +def foo(N, M): + foo = [None] * N # ???? + outer = None + + i = 1 + while i <= N: + o1 = Foo(i) + if i % 3 == 0: + foo[i % M - 1] = o1 + + o2 = Bar(i) + if i % 5 == 0: + o1.setY(o2) + outer = o1 + + i += 1 + +def main(): + N = 4000000 + M = 1000 + foo(N, M) + +main()