From ecdf26078e9528887d968901fdde6a51cf62cd12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Genevi=C3=A8ve=20Bastien?= Date: Fri, 13 Sep 2024 10:11:02 -0400 Subject: [PATCH] batchRouting: subtract startIndex from calc/sec count When a job starts from a checkpoint, we need to substract the `startIndex` from the `completedRoutingCount` to get the actual of calculations done, otherwise we get slowly decreasing results. --- .../src/services/transitRouting/TrRoutingBatch.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/transition-backend/src/services/transitRouting/TrRoutingBatch.ts b/packages/transition-backend/src/services/transitRouting/TrRoutingBatch.ts index 40bf9def..3bfa17d3 100644 --- a/packages/transition-backend/src/services/transitRouting/TrRoutingBatch.ts +++ b/packages/transition-backend/src/services/transitRouting/TrRoutingBatch.ts @@ -142,10 +142,12 @@ class TrRoutingBatch { }; const logOdTripAfter = (index: number) => { if (benchmarkStart >= 0 && index > 0 && index % 100 === 0) { + // Log the calculation speed every 100 calculations. Divide the number of completed calculation (substract startIndex if the task was resumed) by the time taken in seconds. Round to 2 decimals console.log( 'calc/sec', Math.round( - (100 * completedRoutingsCount) / ((1 / 1000) * (performance.now() - benchmarkStart)) + (100 * (completedRoutingsCount - startIndex)) / + ((performance.now() - benchmarkStart) / 1000) ) / 100 ); }