@@ -34,16 +34,30 @@ def execute(self) -> RuntimeInfo:
34
34
f" { self .times } times with { self .name } "
35
35
)
36
36
print (message )
37
- runtimes = [LanguageRunner .run_command (self .command ) for _ in range (self .times )]
38
- return RuntimeInfo (self .day , self .name , sum (runtimes ) / self .times )
37
+
38
+ runtimes : list [float ] = []
39
+ executions : list [float ] = []
40
+ for _ in range (self .times ):
41
+ runtime , execution = LanguageRunner .run_command (self .command )
42
+ runtimes .append (runtime )
43
+ executions .append (execution )
44
+
45
+ return RuntimeInfo (
46
+ day = self .day ,
47
+ language = self .name ,
48
+ runtime = sum (runtimes ) / self .times ,
49
+ execution = sum (executions ) / self .times ,
50
+ )
39
51
40
52
@staticmethod
41
- def run_command (command : list [str ]) -> float :
53
+ def run_command (command : list [str ]) -> tuple [float , float ]:
54
+ start = time .time_ns ()
42
55
result = execute (command )
56
+ execution_ns = float (time .time_ns () - start )
43
57
matches : list [str ] = re .findall (r".*Runtime \(ns\): (\d*)" , result )
44
58
assert len (matches ) == 1 , "Could not find runtime in output"
45
59
runtime_ns = float (matches [0 ])
46
- return runtime_ns / 1_000_000
60
+ return ( runtime_ns / 1_000_000 , execution_ns / 1_000_000 )
47
61
48
62
49
63
@dataclass (frozen = True )
0 commit comments