Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : KA Maps Engine8 * File : sdk/web/scripts/soak-diagnose.mjs9 * Module : sdk10 * Repository : https://git.spboucher.ai/ka-maps-engine11 * Created : 2026-12-0112 * Last Modified : 2026-12-0113 *14 * Author : Simon-Pierre Boucher15 * Position : Professor of Finance16 * Institution : Université du Québec en Outaouais (UQO)17 * Organization : SP Boucher18 * Website : https://spboucher.ai19 * Git : https://git.spboucher.ai20 *21 * Preferred Contact: support@spboucher.ai22 * Development : dev@spboucher.ai23 * Support : support@spboucher.ai24 * Security/Admin : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142// Diagnostic de la mémoire wasm : trois scénarios isolés, en parallèle, sur la démonstration déjà servie43// (tests/e2e/server.mjs, port 5311) — pour savoir QUELLE activité fait monter la mémoire linéaire.44//45// A caméra seule (vols et sauts entre huit lieux, 2D/3D)46// B caméra fixe sur deux vues + changements de thème et de marque47// C caméra fixe sur deux vues + les huit couches ajoutées et retirées48//49// node tests/e2e/server.mjs & puis node scripts/soak-diagnose.mjs [minutes]50import { chromium } from '@playwright/test';5152const MINUTES = Number(process.argv[2] ?? 5);53const URL_ = process.env.KA_DEMO_URL ?? 'http://127.0.0.1:5311/';54const GPU = ['--enable-unsafe-webgpu', '--enable-gpu', '--use-angle=metal', '--ignore-gpu-blocklist', '--enable-features=WebGPU', '--js-flags=--expose-gc', '--enable-precise-memory-info'];5556const scenarios = {57 A: () => {58 const m = window.kaMap;59 const places = [[-73.5674, 45.5019, 14.5], [-73.62, 45.53, 13], [-71.208, 46.8139, 14.5], [-71.25, 46.83, 12], [-71.9, 48.5, 11], [-72.2, 48.4, 9], [-73.75, 45.57, 15.5], [-73.55, 45.51, 16.5]];60 let step = 0;61 setInterval(() => {62 step++;63 const p = places[step % places.length];64 if (step % 4 === 0) m.jumpTo({ center: [p[0], p[1]], zoom: p[2] });65 else m.flyTo({ center: [p[0], p[1]], zoom: p[2], bearing: (step * 37) % 360, pitch: step % 3 === 0 ? 55 : 0 }, { duration: 2200 });66 if (step % 6 === 0) m.setMode(step % 12 === 0 ? '3d' : '2d');67 }, 2500);68 },69 B: () => {70 const m = window.kaMap;71 const themes = ['signature', 'midnight', 'minimal', 'terrain', 'financial', 'blueprint', 'city3d'];72 const brands = [null, 'louka', 'immoka', 'vraiprix', 'valoplex'];73 let step = 0;74 setInterval(() => {75 step++;76 if (step % 2 === 0) void m.setTheme(themes[(step / 2) % themes.length]);77 else m.setBrand(brands[step % brands.length]);78 m.jumpTo({ center: step % 4 < 2 ? [-73.5674, 45.5019] : [-73.58, 45.51], zoom: 14.5 });79 }, 2500);80 },81 C: () => {82 const m = window.kaMap;83 let step = 0;84 setInterval(() => {85 step++;86 const name = window.kaDemo.layerNames[step % window.kaDemo.layerNames.length];87 window.kaDemo.setLayer(name, !m.hasLayer(name));88 m.jumpTo({ center: step % 4 < 2 ? [-73.5674, 45.5019] : [-73.58, 45.51], zoom: 14.5 });89 }, 2500);90 },91};9293const browser = await chromium.launch({ headless: true, channel: 'chromium', args: GPU });94const pages = {};95for (const [name, fn] of Object.entries(scenarios)) {96 const ctx = await browser.newContext({ viewport: { width: 1280, height: 800 } });97 const page = await ctx.newPage();98 await page.goto(`${URL_}?layers=&quality=high&reduced=0&cache=0`);99 await page.waitForFunction(() => window.kaDemo?.ready, null, { timeout: 60000 });100 await page.evaluate(fn);101 pages[name] = page;102}103const series = { A: [], B: [], C: [] };104const t0 = Date.now();105while (Date.now() - t0 < MINUTES * 60000) {106 await new Promise((r) => setTimeout(r, 15000));107 const line = [];108 for (const [name, page] of Object.entries(pages)) {109 const mb = await page.evaluate(() => {110 window.gc?.();111 const s = window.kaMap.getStats();112 return [+(s.wasmMemoryBytes / 1048576).toFixed(1), +((s.wasmLiveBytes ?? 0) / 1048576).toFixed(1)];113 });114 series[name].push(mb);115 line.push(`${name} linéaire ${mb[0]} vivants ${mb[1]}`);116 }117 console.log(`${Math.round((Date.now() - t0) / 1000)} s : ${line.join(' ')}`);118}119console.log(JSON.stringify(series));120await browser.close();121