Skip to content

Commit 20560ef

Browse files
committed
Records: Try only saving averages to save memory
1 parent a0ef705 commit 20560ef

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

utils/records.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,14 @@ export const handler: Handler = async (event: any, context?: any) => {
230230
const t2 = new Date(g.stack[i+1]._timestamp).getTime();
231231
times.push(t2 - t1);
232232
}
233-
times.forEach((t, i) => pushToMap(ttm, gdata.players[i % g.numplayers].id, t));
233+
const interim = new Map<string, number[]>();
234+
times.forEach((t, i) => pushToMap(interim, gdata.players[i % g.numplayers].id, t));
235+
for (const [player, lst] of interim.entries()) {
236+
if (lst.length > 0) {
237+
const avg = lst.reduce((a, b) => a + b, 0) / lst.length;
238+
pushToMap(ttm, player, avg);
239+
}
240+
}
234241
}
235242
console.log(`allRecs: ${allRecs.length}, metaRecs: ${[...metaRecs.keys()].length}, userRecs: ${[...userRecs.keys()].length}, eventRecs: ${[...eventRecs.keys()].length}`);
236243

0 commit comments

Comments
 (0)