@slot-engine/core 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +31 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2471,6 +2471,24 @@ var Simulation = class {
|
|
|
2471
2471
|
const lookupSegmentedStream = import_fs3.default.createWriteStream(tempLookupSegPath, {
|
|
2472
2472
|
highWaterMark: this.maxHighWaterMark
|
|
2473
2473
|
});
|
|
2474
|
+
const WRITE_BATCH_SIZE = 200;
|
|
2475
|
+
let booksIndexBatch = [];
|
|
2476
|
+
let lookupBatch = [];
|
|
2477
|
+
let lookupSegBatch = [];
|
|
2478
|
+
const flushWriteBatches = async () => {
|
|
2479
|
+
if (booksIndexBatch.length === 0) return;
|
|
2480
|
+
const booksIndexData = booksIndexBatch.join("");
|
|
2481
|
+
const lookupData = lookupBatch.join("");
|
|
2482
|
+
const lookupSegData = lookupSegBatch.join("");
|
|
2483
|
+
booksIndexBatch = [];
|
|
2484
|
+
lookupBatch = [];
|
|
2485
|
+
lookupSegBatch = [];
|
|
2486
|
+
await Promise.all([
|
|
2487
|
+
write(booksIndexStream, booksIndexData),
|
|
2488
|
+
write(lookupStream, lookupData),
|
|
2489
|
+
write(lookupSegmentedStream, lookupSegData)
|
|
2490
|
+
]);
|
|
2491
|
+
};
|
|
2474
2492
|
let writeChain = Promise.resolve();
|
|
2475
2493
|
worker.on("message", (msg) => {
|
|
2476
2494
|
if (msg.type === "log" || msg.type === "user-log") {
|
|
@@ -2550,20 +2568,19 @@ var Simulation = class {
|
|
|
2550
2568
|
if (!this.tempBookIndexPaths.includes(booksIndexPath)) {
|
|
2551
2569
|
this.tempBookIndexPaths.push(booksIndexPath);
|
|
2552
2570
|
}
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
booksIndexStream,
|
|
2556
|
-
`${book.id},${index},${this.bookChunkIndexes.get(index) || 0}
|
|
2571
|
+
booksIndexBatch.push(
|
|
2572
|
+
`${book.id},${index},${this.bookChunkIndexes.get(index) || 0}
|
|
2557
2573
|
`
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
`)
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
`${book.id},${book.criteria},${book.basegameWins},${book.freespinsWins}
|
|
2574
|
+
);
|
|
2575
|
+
lookupBatch.push(`${book.id},1,${Math.round(book.payout)}
|
|
2576
|
+
`);
|
|
2577
|
+
lookupSegBatch.push(
|
|
2578
|
+
`${book.id},${book.criteria},${book.basegameWins},${book.freespinsWins}
|
|
2564
2579
|
`
|
|
2565
|
-
|
|
2566
|
-
|
|
2580
|
+
);
|
|
2581
|
+
if (booksIndexBatch.length >= WRITE_BATCH_SIZE) {
|
|
2582
|
+
await flushWriteBatches();
|
|
2583
|
+
}
|
|
2567
2584
|
if (this.bookBufferSizes.get(index) >= 10 * 1024 * 1024) {
|
|
2568
2585
|
await flushBookChunk();
|
|
2569
2586
|
}
|
|
@@ -2584,6 +2601,7 @@ var Simulation = class {
|
|
|
2584
2601
|
}
|
|
2585
2602
|
if (msg.type === "done") {
|
|
2586
2603
|
writeChain.then(async () => {
|
|
2604
|
+
await flushWriteBatches();
|
|
2587
2605
|
await flushBookChunk();
|
|
2588
2606
|
lookupStream.end();
|
|
2589
2607
|
lookupSegmentedStream.end();
|
|
@@ -3399,6 +3417,7 @@ var Analysis = class {
|
|
|
3399
3417
|
properties: data.properties,
|
|
3400
3418
|
count: data.count,
|
|
3401
3419
|
hitRateString: `1 in ${Math.round(hitRate).toLocaleString()}`,
|
|
3420
|
+
hitRatePercentage: round(1 / hitRate * 100, 4),
|
|
3402
3421
|
hitRate
|
|
3403
3422
|
};
|
|
3404
3423
|
}).sort((a, b) => a.hitRate - b.hitRate);
|