Performance profiling
Aggregate per-opcode gas usage directly from native Guillotine Mini debug_traceCall traces:
Native Opcode Tracing with debug_traceCall
import { createMemoryClient } from 'tevm'
const client = createMemoryClient()
try {
const target = '0x0000000000000000000000000000000000000123'
await client.tevmSetAccount({
address: target,
deployedBytecode: '0x602a60005260206000f3',
})
const trace = (await client.transport.tevm.request({
method: 'debug_traceCall',
params: [{ to: target }, 'latest', { disableStack: true }],
})) as { gas: number; structLogs: Array<{ op: string; gasCost: number }> }
const gasByOpcode = new Map<string, number>()
for (const step of trace.structLogs) {
gasByOpcode.set(step.op, (gasByOpcode.get(step.op) ?? 0) + step.gasCost)
}
console.log({ totalGas: trace.gas, gasByOpcode })
} finally {
await client.tevmClose()
}Pass disableStack: true when you only need opcode counts and gas costs to keep trace payloads small. See Tracing & engine events.

