Master the fundamental concepts of build a bytecode vm through this focused micro-challenge.
You cannot optimize what you do not measure. Comparing your interpreter against CPython on the same workload reveals whether dispatch, allocation, or call overhead dominates.
Sound micro-benchmarks follow a few rules:
Dispatch styles matter:
For example, `fib(35)` in bytecode versus the same algorithm in native C often shows a 50x or larger gap, mostly from per-opcode dispatch.
Use `clock()` from `<time.h>` and report milliseconds per iteration.
Report at least median and spread, not a single timing sample. OS jitter and cache warmth dominate short runs; three warmup iterations plus five measured runs is a minimal credible methodology for comparing interpreter variants.
This exercise asks you to benchmark recursive Fibonacci in your VM against a C baseline. You will implement warmup runs, timed iterations, and printed comparison so you know where cycles go before optimizing.
Write a benchmarking program for your VM in C.
Requirements:
Test:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it works