1717import time
1818from dataclasses import dataclass
1919
20- from typing import cast , Any , Callable , Dict , Iterable , List , Tuple
20+ from typing import cast , Any , Dict , List , Tuple
21+ from collections .abc import Callable , Iterable
2122
2223logging .basicConfig (level = logging .INFO )
2324log = logging .getLogger (__name__ )
@@ -85,9 +86,9 @@ def get_file_hash(binary_path: str) -> str:
8586 return d
8687
8788
88- def get_blocks (binary_path : str ) -> List [Block ]:
89+ def get_blocks (binary_path : str ) -> list [Block ]:
8990 blocks_file_path = f"blocks_{ get_file_hash (binary_path )[0 :8 ]} .cache"
90- blocks : List [Block ] = []
91+ blocks : list [Block ] = []
9192
9293 if not os .path .exists (blocks_file_path ):
9394 log .info ("Recovering blocks from CFG..." )
@@ -121,7 +122,7 @@ def get_blocks(binary_path: str) -> List[Block]:
121122 return blocks
122123
123124
124- def benchmark_pypcode (blocks : List [Block ], iter_ops : bool = False , iter_varnodes : bool = False ) -> BenchmarkResult :
125+ def benchmark_pypcode (blocks : list [Block ], iter_ops : bool = False , iter_varnodes : bool = False ) -> BenchmarkResult :
125126 assert pypcode is not None
126127
127128 start_time = time .time ()
@@ -144,7 +145,7 @@ def benchmark_pypcode(blocks: List[Block], iter_ops: bool = False, iter_varnodes
144145 return BenchmarkResult (startup_duration , translation_duration )
145146
146147
147- def benchmark_pypcode_disassembly (blocks : List [Block ]) -> BenchmarkResult :
148+ def benchmark_pypcode_disassembly (blocks : list [Block ]) -> BenchmarkResult :
148149 assert pypcode is not None
149150
150151 start_time = time .time ()
@@ -161,7 +162,7 @@ def benchmark_pypcode_disassembly(blocks: List[Block]) -> BenchmarkResult:
161162 return BenchmarkResult (startup_duration , translation_duration )
162163
163164
164- def benchmark_pyvex (blocks : List [Block ], ** vex_args ) -> BenchmarkResult :
165+ def benchmark_pyvex (blocks : list [Block ], ** vex_args ) -> BenchmarkResult :
165166 assert pyvex is not None
166167
167168 start_time = time .time ()
@@ -176,7 +177,7 @@ def benchmark_pyvex(blocks: List[Block], **vex_args) -> BenchmarkResult:
176177 return BenchmarkResult (startup_duration , translation_duration )
177178
178179
179- def benchmark_capstone (blocks : List [Block ], lite : bool = False ) -> BenchmarkResult :
180+ def benchmark_capstone (blocks : list [Block ], lite : bool = False ) -> BenchmarkResult :
180181 assert capstone is not None
181182
182183 start_time = time .time ()
@@ -199,9 +200,9 @@ def benchmark_capstone(blocks: List[Block], lite: bool = False) -> BenchmarkResu
199200
200201
201202def gen_benchmarks_from_configurations (
202- name : str , benchmark_func : Callable , configurations : List [ Dict [str , Any ]]
203- ) -> List [ Tuple [str , Callable ]]:
204- benchmarks : List [ Tuple [str , Callable ]] = []
203+ name : str , benchmark_func : Callable , configurations : list [ dict [str , Any ]]
204+ ) -> list [ tuple [str , Callable ]]:
205+ benchmarks : list [ tuple [str , Callable ]] = []
205206 for config in configurations :
206207 name_append = ""
207208 if config :
@@ -239,7 +240,7 @@ def main() -> None:
239240 for name , version , import_duration in imports :
240241 log .info ("%s v%s took %.2f ms to import" , name , version , import_duration * 1000 )
241242
242- benchmarks : List [ Tuple [str , Callable ]] = []
243+ benchmarks : list [ tuple [str , Callable ]] = []
243244 if HAVE_CAPSTONE and "capstone" not in args .skip :
244245 benchmarks .extend (
245246 gen_benchmarks_from_configurations (
@@ -300,7 +301,7 @@ def main() -> None:
300301 log .info ("Benchmark includes %d blocks totaling %.1f KiB" , num_blocks , blocks_total_size / 1024 )
301302
302303 gc .collect ()
303- results : List [ Tuple [str , BenchmarkResult ]] = []
304+ results : list [ tuple [str , BenchmarkResult ]] = []
304305 gc .disable ()
305306 for name , benchmark in benchmarks :
306307 log .info ("Benchmarking %s performance..." , name )
0 commit comments