集成旋转底座、机械臂示教与坐标系,完善扫描参数、电量和框架点复用。增加组合执行、步骤进度与日志,优化首屏和流程画布性能,修复表头主题适配,并保留验证脚本和回归测试。
43 lines
2.7 KiB
JavaScript
43 lines
2.7 KiB
JavaScript
/** Isolated CPU comparison of the previous graph-copy lookup and the reactive view index.
|
|
* Does not measure browser FPS or interact with persisted workflows/devices.
|
|
*/
|
|
import { ref, computed } from '../am-web/node_modules/vue/index.mjs'
|
|
import { performance } from 'node:perf_hooks'
|
|
import { createFlowFacade } from '../am-web/src/cmvr/common/views/flow/vue-flow/adapter.js'
|
|
import { createFlowViewIndex, executionTargetLabel } from '../am-web/src/cmvr/common/views/flow/vue-flow/viewIndex.mjs'
|
|
|
|
function measure(mode, count = 300) {
|
|
const nodes = ref([]), edges = ref([])
|
|
const store = { getNodes: nodes, getEdges: edges,
|
|
setNodes: value => { nodes.value = value }, setEdges: value => { edges.value = value },
|
|
findNode: id => nodes.value.find(node => node.id === id), updateNodeInternals() {} }
|
|
const facade = createFlowFacade(store)
|
|
facade.render({ nodes: [
|
|
{ id: 'start', type: 'start', x: 0, y: 0, properties: { resourceRoles: [{ roleKey: 'scan', displayName: '扫描工位', deviceSlots: [] }] } },
|
|
...Array.from({ length: count }, (_, i) => ({ id: `n${i}`, type: 'serviceNode', x: i * 200, y: 0,
|
|
properties: { name: `步骤${i}`, action: 'SCANNER_STATE', executionTarget: { roleKey: 'scan' },
|
|
nodeParams: Array.from({ length: 8 }, (_, j) => ({ name: `field${j}`, type: 'input', input: j })) } }))
|
|
], edges: [] })
|
|
let graphCopies = 0, evaluations = 0
|
|
const getGraph = () => { graphCopies++; return facade.getGraphData() }
|
|
const index = createFlowViewIndex(nodes)
|
|
const labels = nodes.value.slice(1).map(node => computed(() => {
|
|
evaluations++
|
|
if (mode === 'indexed') return executionTargetLabel(node.data.properties.executionTarget, index.rolesByKey.value)
|
|
const start = getGraph().nodes.find(item => item.type === 'start')
|
|
return start.properties.resourceRoles.find(item => item.roleKey === node.data.properties.executionTarget.roleKey).displayName
|
|
}))
|
|
const read = () => labels.forEach(label => { if (label.value !== '扫描工位') throw new Error('Label mismatch') })
|
|
const initial = performance.now()
|
|
read()
|
|
const initialMs = performance.now() - initial
|
|
const copiesBeforeDrag = graphCopies, evaluationsBeforeDrag = evaluations
|
|
nodes.value[1].position.x += 10
|
|
const dragStart = performance.now()
|
|
read()
|
|
return { mode, count, initialMs: +initialMs.toFixed(2), afterMoveMs: +(performance.now() - dragStart).toFixed(2),
|
|
initialGraphCopies: copiesBeforeDrag, graphCopiesAfterMove: graphCopies - copiesBeforeDrag,
|
|
labelEvaluationsAfterMove: evaluations - evaluationsBeforeDrag }
|
|
}
|
|
console.log(JSON.stringify({ scope: 'Isolated Node/Vue computation, not browser FPS', results: [measure('previous'), measure('indexed')] }, null, 2))
|