Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : KA Maps Engine8 * File : sdk/web/scripts/ready-ab.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// Mesure de « prête » (événement load) : alternance upload=spread (étalement du moteur, comme 0.3.0) / défaut 0.4.0.43import { chromium } from '@playwright/test';44const b = await chromium.launch({ headless: true, channel: 'chromium', args: ['--enable-unsafe-webgpu', '--enable-gpu', '--use-angle=metal', '--ignore-gpu-blocklist', '--enable-features=WebGPU'] });45const res = { spread: { cold: [], warm: [] }, fast: { cold: [], warm: [] } };46for (let i = 0; i < 8; i++) for (const mode of i % 2 ? ['fast', 'spread'] : ['spread', 'fast']) {47 const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });48 const p = await ctx.newPage();49 const url = `http://127.0.0.1:5311/?layers=&quality=high${mode === 'spread' ? '&upload=spread' : ''}`;50 for (const kind of ['cold', 'warm']) {51 const t0 = Date.now();52 await (kind === 'cold' ? p.goto(url) : p.reload());53 await p.waitForFunction(() => window.kaDemo?.ready);54 res[mode][kind].push(Date.now() - t0);55 await p.evaluate(() => window.kaMap.offline.flush());56 }57 await ctx.close();58}59const med = (a) => [...a].sort((x, y) => x - y)[Math.floor(a.length / 2)];60for (const m of ['spread', 'fast']) for (const k of ['cold', 'warm']) console.log(m, k, 'médiane', med(res[m][k]), 'ms ; min', Math.min(...res[m][k]), '; max', Math.max(...res[m][k]), '; n', res[m][k].length);61await b.close();62