-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_counts_silent.js
More file actions
73 lines (61 loc) · 2.76 KB
/
Copy pathverify_counts_silent.js
File metadata and controls
73 lines (61 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const { spawn } = require('child_process');
const fs = require('fs');
async function runOrchestrator(name, scriptPath, durationMs) {
return new Promise((resolve) => {
console.log(`\n--- Running ${name} (${durationMs}ms) ---`);
const env = { ...process.env, DATA_PATH: '' };
// Use 'pipe' for stdout to capture data, 'ignore' for stderr to suppress warnings if possible
const orchestrator = spawn('node', [scriptPath], {
stdio: ['ignore', 'pipe', 'ignore'],
env
});
let capturedCounts = [];
let r2rCounts = [];
orchestrator.stdout.on('data', (data) => {
const str = data.toString();
// Fetching logs
if (name === 'Fetching' && str.includes('Processing valid result')) {
const match = str.match(/count: (\d+)/);
if (match) {
console.log(`[${name}] Captured Result Count: ${match[1]}`);
capturedCounts.push(parseInt(match[1]));
}
}
// Chunked logs (Aggregator)
if (name === 'Chunked' && str.includes('Executing the R2R Operator')) {
const counts = [...str.matchAll(/hasCount> \\"(\d+)\\"/g)].map(m => parseInt(m[1]));
const sum = counts.reduce((a, b) => a + b, 0);
console.log(`[${name}] Chunk Aggregation Input Sum: ${sum}`);
r2rCounts.push(sum);
}
});
setTimeout(() => {
console.log(`[${name}] Starting Publisher...`);
const publisher = spawn('node', ['dist/streamer/src/publish.js'], {
stdio: ['ignore', 'ignore', 'ignore'], // SILENCE THE PUBLISHER
env
});
setTimeout(() => {
console.log(`[${name}] Stopping...`);
publisher.kill();
orchestrator.kill();
resolve({ capturedCounts, r2rCounts });
}, durationMs);
}, 5000); // Give orchestrator 5s to settle
});
}
async function main() {
console.log("Starting Silent Verification...");
// FETCHING (180s to be safe)
const fetchResults = await runOrchestrator('Fetching', 'dist/approaches/StreamingQueryFetchingClientSideApproachOrchestrator.js', 180000);
// CHUNKED (180s to be safe)
const chunkResults = await runOrchestrator('Chunked', 'dist/approaches/StreamingQueryChunkedApproachOrchestrator.js', 180000);
const analysis = `
--- FINAL ANALYSIS ---
Fetching Counts: ${fetchResults.capturedCounts.join(', ')}
Chunked Aggregation Sums: ${chunkResults.r2rCounts.join(', ')}
`;
console.log(analysis);
fs.writeFileSync('verify_output.txt', analysis);
}
main();