فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

test(a08): sample native Windows process tree memory per cycle

Davood Mehraban committed Nov 23, 2026 at 22:55 UTC 369ba0be5077ba969ce264146a1ceb2dda8f8b8e
1 file changed +32 -2
tests/windows-vm-installed-tauri-cdp.cjs
+32 -2
@@ -648,6 +648,34 @@ async function connect(url) {
648 assert.ok(Number.isSafeInteger(usage.usedSize) && usage.usedSize >= 0);
649 return { usedBytes: usage.usedSize, allocatedBytes: usage.totalSize };
650 };
651 + // Windows process tree metrics are distinct from CDP renderer JS heap.
652 + // Capture installed Tauri parent + descendants using OS process counters.
653 + // A transient CIM failure is recorded, not converted to a zero reading.
654 + const windowsProcessMemory = () => {
655 + try {
656 + const script = [
657 + '$ErrorActionPreference = "Stop"',
658 + '$all = @(Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,WorkingSetSize,PrivatePageCount)',
659 + '$ids = [System.Collections.Generic.HashSet[int]]::new()',
660 + '[void]$ids.Add(' + proc.pid + ')',
661 + 'do { $before = $ids.Count; foreach ($p in $all) { if ($ids.Contains([int]$p.ParentProcessId)) { [void]$ids.Add([int]$p.ProcessId) } } } while ($ids.Count -gt $before)',
662 + '$members = @($all | Where-Object { $ids.Contains([int]$_.ProcessId) })',
663 + 'if ($members.Count -lt 1) { throw "Installed process not found" }',
664 + '$ws = ($members | Measure-Object -Property WorkingSetSize -Sum).Sum',
665 + '$private = ($members | Measure-Object -Property PrivatePageCount -Sum).Sum',
666 + '@{ processCount=$members.Count; workingSetBytes=[long]$ws; privateBytes=[long]$private } | ConvertTo-Json -Compress'
667 + ].join('; ');
668 + const sample = JSON.parse(execFileSync('powershell.exe',
669 + ['-NoProfile', '-NonInteractive', '-Command', script],
670 + { encoding: 'utf8', timeout: 30000 }));
671 + assert.ok(Number.isSafeInteger(sample.workingSetBytes) &&
672 + sample.workingSetBytes > 0 && Number.isSafeInteger(sample.privateBytes) &&
673 + sample.privateBytes > 0 && sample.processCount > 0);
674 + return sample;
675 + } catch (error) {
676 + return { unavailable: true, reason: 'Windows CIM process-tree sample unavailable' };
677 + }
678 + };
679 let gcSupported = true;
680 const collect = async () => {
681 try { await cdp.command('HeapProfiler.collectGarbage', {}, 30000); }
@@ -655,6 +683,7 @@ async function connect(url) {
683 };
684 await collect();
685 const baseline = await heap();
686 + const processBaseline = windowsProcessMemory();
687 for (let i = 0; i < 10; i++) {
688 const result = await cdp.evaluate(cycleCode, 120000);
689 assert.equal(result.products, 10000);
@@ -665,11 +694,12 @@ async function connect(url) {
694 if (gcSupported) await collect();
695 const postGc = gcSupported ? await heap() : null;
696 cycles.push({ cycle: i + 1, durationMs: result.rounds[0].durationMs,
668 - raw, postGc });
697 + raw, postGc, windowsProcessTree: windowsProcessMemory() });
698 }
699 report.nativeMemoryStability = {
671 - status: 'PASSED', synthetic: true, cycles, baseline,
700 + status: 'PASSED', synthetic: true, cycles, baseline, processBaseline,
701 gcSupported, heapScope: 'renderer-js-heap-not-Windows-working-set',
702 + windowsProcessScope: 'installed-Tauri-parent-and-descendant-processes',
703 note: 'Diagnostic series only; no leak verdict or SLA implied'
704 };
705 }