File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 8080 }
8181});
8282
83- test ('globalTimer is the wall-clock of the full computation (nested entries sum to more) ' , function (): void {
83+ test ('globalTimer equals the span from first chrono start to last chrono end ' , function (): void {
8484 $ this ->election ->parseVotes ('A>B>C ' );
8585 $ this ->election ->getResult ('Schulze ' );
8686
8787 $ history = $ this ->election ->getTimerManager ()->getHistory ();
88- $ sumProcessIn = (float ) array_sum (array_column ($ history , 'process_in ' ));
8988
9089 expect ($ this ->election ->getGlobalTimer ())->toBeGreaterThan (0.0 );
9190
92- // Nested chronos overlap in time: their individual durations add up to MORE than
93- // the outer wall-clock. globalTimer = last_end - first_start (no double-counting).
94- expect ($ sumProcessIn )->toBeGreaterThanOrEqual ($ this ->election ->getGlobalTimer ());
91+ // globalTimer = last_end - startDeclare.
92+ // startDeclare is the start of the very first chrono (history[0].timer_start).
93+ // The last chrono to destruct is always the outermost one (history last entry).
94+ $ expectedGlobalTimer = end ($ history )['timer_end ' ] - $ history [0 ]['timer_start ' ];
95+ expect ($ this ->election ->getGlobalTimer ())->toEqualWithDelta ($ expectedGlobalTimer , 1e-9 );
96+
97+ // Each individual process_in fits within the global span (no entry can be longer than total).
98+ foreach ($ history as $ entry ) {
99+ expect ($ entry ['process_in ' ])->toBeLessThanOrEqual ($ this ->election ->getGlobalTimer () + 1e-9 );
100+ }
95101});
96102
97103test ('history contains Do Pairwise entry on first vote ' , function (): void {
You can’t perform that action at this time.
0 commit comments