@@ -16,18 +16,32 @@ def process_diagnostic(diag):
16
16
engine = diagnostic .Engine ()
17
17
engine .process = process_diagnostic
18
18
19
- modules = []
19
+ # Make sure everything's valid
20
+ modules = [Module .from_filename (filename , engine = engine )
21
+ for filename in sys .argv [1 :]]
22
+
23
+ def benchmark (f , name ):
24
+ start = time .perf_counter ()
25
+ end = 0
26
+ runs = 0
27
+ while end - start < 5 or runs < 10 :
28
+ f ()
29
+ runs += 1
30
+ end = time .perf_counter ()
31
+
32
+ print ("{} {} runs: {:.2f}s, {:.2f}ms/run" .format (
33
+ runs , name , end - start , (end - start ) / runs * 1000 ))
34
+
35
+ sources = []
20
36
for filename in sys .argv [1 :]:
21
- modules .append (Module .from_filename (filename , engine = engine ))
37
+ with open (filename ) as f :
38
+ sources .append (f .read ())
22
39
23
- runs = 100
24
- start = time .perf_counter ()
25
- for _ in range (runs ):
26
- llobj = OR1KTarget ().compile_and_link (modules )
27
- end = time .perf_counter ()
40
+ benchmark (lambda : [Module .from_string (src ) for src in sources ],
41
+ "ARTIQ typechecking and transforms" )
28
42
29
- print ( "{} compilation runs: {:.2f}s, {:.2f}ms/run" . format (
30
- runs , end - start , ( end - start ) / runs * 1000 ) )
43
+ benchmark ( lambda : OR1KTarget (). compile_and_link ( modules ),
44
+ "LLVM optimization and linking" )
31
45
32
46
if __name__ == "__main__" :
33
47
main ()
0 commit comments