mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
timeline: read each entry's time once when merging runs
mergeTimelineRuns read an entry's time again on every comparison, and the vessel layer passed a new arrow for every vessel. Times are now read once into arrays, the leading older entries the loop would keep one by one are sliced in one step, and the layer passes one function. The result is the same entries in the same order; a test checks 3,000 random merges against the previous algorithm. Measured in the browser, one implementation per page, 9,000 vessels with 240 kept fixes each, 5 alternating pairs: 65-87 ms -> 57-61 ms per snapshot.
This commit is contained in:
1 parent
b65bb86db3
commit
121b69561a
3 files changed
+132
-13
No files matched your search
@@ -58,6 +58,9 @@ function stampFix(record, receivedAtMs, feedLatestEpoch) {
|
||||
record.fixFeedEpoch = feedLatestEpoch;
|
||||
}
|
||||
|
||||
/** A fix's time, as the fixes are merged (one function for every vessel). */
|
||||
const fixTime = (fix) => fix.atMs;
|
||||
|
||||
function positiveNumber(value) {
|
||||
const number = finiteNumber(value);
|
||||
return number !== null && number > 0 ? number : null;
|
||||
@@ -164,7 +167,7 @@ export class VesselRecords {
|
||||
? mergeTimelineRuns(
|
||||
record.fixes ?? [],
|
||||
next.fixes,
|
||||
(fix) => fix.atMs,
|
||||
fixTime,
|
||||
(next.lastPositionEpoch ?? 0) * 1000,
|
||||
)
|
||||
: null;
|
||||
|
||||
Reference in new issue
Block a user