Add scanner API integration, workflow components, execution-bound live images and 3D model viewing. Harden task control, parameters, resource protection and reports, with automated regressions and detailed verification records.
34 lines
2.0 KiB
JavaScript
34 lines
2.0 KiB
JavaScript
/** Reproducible local point-cloud benchmark; no service or hardware access. */
|
|
import { performance } from 'node:perf_hooks'
|
|
import { writeFile } from 'node:fs/promises'
|
|
import { parseScannerModel, disposeScannerModel } from '../am-web/src/views/lab/scan-task/scannerModel.mjs'
|
|
import { hydrateScannerModel } from '../am-web/src/views/lab/scan-task/scannerModelTransfer.mjs'
|
|
import { parseScannerModelAsync } from '../am-web/src/views/lab/scan-task/scannerModelWorker.mjs'
|
|
import { binaryPointCloud, nodeModelWorker } from '../am-web/src/views/lab/scan-task/scannerModelWorkerTestHelper.mjs'
|
|
|
|
const result = { environment: 'Node worker threads; binary PLY with RGB; not a browser FPS benchmark', samples: [] }
|
|
for (const count of [100000, 1000000]) {
|
|
const sample = { points: count, bytes: 0 }
|
|
for (const mode of ['synchronous', 'worker']) {
|
|
const input = binaryPointCloud(count); sample.bytes = input.byteLength
|
|
let last = performance.now(), maxGap = 0, ticks = 0
|
|
const timer = setInterval(() => { const now = performance.now(); maxGap = Math.max(maxGap, now-last); last=now; ticks++ },5)
|
|
await new Promise(resolve=>setTimeout(resolve,15))
|
|
const started = performance.now()
|
|
let model
|
|
if (mode === 'synchronous') model = parseScannerModel(input,'benchmark.ply')
|
|
else {
|
|
const data = await parseScannerModelAsync(input,'benchmark.ply',undefined,nodeModelWorker)
|
|
const hydration = performance.now(); model = hydrateScannerModel(data)
|
|
sample.hydrateMs = performance.now()-hydration; sample.workerParseMs=data.parseMs
|
|
}
|
|
const elapsedMs = performance.now()-started
|
|
await new Promise(resolve=>setTimeout(resolve,15)); clearInterval(timer)
|
|
sample[mode] = { elapsedMs, maxEventLoopGapMs:maxGap, heartbeatTicks:ticks, displayedPoints:model.displayedPoints??model.points }
|
|
disposeScannerModel(model.object)
|
|
}
|
|
result.samples.push(sample)
|
|
}
|
|
await writeFile(new URL('../.local/scanner-model-performance.json',import.meta.url),JSON.stringify(result,null,2))
|
|
process.stdout.write(JSON.stringify(result,null,2)+'\n')
|