1- import sys
1+ import multiprocessing
22from pathlib import Path
33from typing import Tuple
44
5- import arcade
6-
75from benchmark .timing import PerformanceTiming
86
97
10- class PerfTest :
8+ class PerfTest ( multiprocessing . Process ) :
119 name = "default"
1210 type = "default"
1311 series_name = "default"
1412 instances = []
1513
1614 def __init__ (
1715 self ,
16+ session_dir : Path ,
1817 size : Tuple [int , int ],
1918 title : str = "Perf Test" ,
2019 start_count : int = 0 ,
2120 increment_count : int = 100 ,
2221 duration : float = 60.0 ,
2322 ** kwargs ,
2423 ):
24+ super ().__init__ ()
25+ self .session_dir = session_dir
2526 self .size = size
2627 self .title = title
2728 self .start_count = start_count
@@ -43,9 +44,9 @@ def on_update(self, delta_time: float):
4344 def update_state (self ):
4445 pass
4546
46- def run (self , session_dir : Path ):
47+ def run (self ):
4748 self .frame = 0
48- out_path = session_dir / "data"
49+ out_path = self . session_dir / "data"
4950 out_path .mkdir (parents = True , exist_ok = True )
5051
5152 self .timing = PerformanceTiming (
@@ -61,6 +62,7 @@ class ArcadePerfTest(PerfTest):
6162
6263 def __init__ (
6364 self ,
65+ session_dir : Path ,
6466 size : Tuple [int , int ],
6567 title : str = "Perf Test" ,
6668 start_count : int = 0 ,
@@ -69,6 +71,7 @@ def __init__(
6971 ** kwargs ,
7072 ):
7173 super ().__init__ (
74+ session_dir ,
7275 size = size ,
7376 title = title ,
7477 start_count = start_count ,
@@ -99,9 +102,9 @@ def run_test(self):
99102 self .update_state ()
100103 self .window .flip ()
101104
102- def run (self , session_dir : Path ):
105+ def run (self ):
103106 """Run the test collecting data."""
104- super ().run (session_dir )
107+ super ().run ()
105108 self .create_window ()
106109 self .setup ()
107110
@@ -129,6 +132,7 @@ def run(self, session_dir: Path):
129132 self .timing .write ()
130133
131134 def create_window (self ):
135+ import arcade
132136 try :
133137 self .window = arcade .get_window ()
134138 self .window .set_size (* self .size )
@@ -142,22 +146,4 @@ def create_window(self):
142146
143147
144148class AcceleratedPerfTest (ArcadePerfTest ):
145- type = "arcade-accelerate"
146-
147- def run (self , session_dir : Path ):
148- # This is necessary to unload arcade and ensure that we have the arcade-accelerate bootstrap applied
149- # The test module itself is responsbile for applying the bootstrap, but arcade needs to be fully unloaded before then
150- to_uncache = []
151- for mod in sys .modules :
152- if mod .startswith ("arcade." ):
153- to_uncache .append (mod )
154-
155- for mod in to_uncache :
156- del sys .modules [mod ]
157-
158- import arcade_accelerate
159-
160- arcade_accelerate .bootstrap ()
161- import arcade
162-
163- super ().run (session_dir )
149+ type = "accelerate"
0 commit comments