Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Performance profiling

Aggregate per-opcode gas usage directly from native Guillotine Mini debug_traceCall traces:

Native Opcode Tracing with debug_traceCall
debug_traceCallcall object + blockTagenableMemory: trueenableReturnData: truedisableStack / StorageGuillotine Mini TracerSnapshots before each opcode:pc · op · gas · gasCost · depthstack[] · memory[] · returnDataCap: 100,000 stepsTrace Payloadgas: 21018failed: falsereturnValue: "0x...2a"truncated: falsestructLogs: [...]
Guillotine Mini records pre-opcode stack, memory, gas, and returnData inside native code and returns a bounded structLogs array.
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.