Type switches
Walk 100k heterogeneous values and dispatch by runtime type. Tests the type-assertion / type-switch path.
Compile time · median (cold)
Full statistics
| Runner | N | Compile | Runtime | P95 | Stddev | RSS | vs pipit | Status |
|---|---|---|---|---|---|---|---|---|
| Native Gocompiled | 7 | 108 ms | 645 µs | 664 µs | 9.60 µs | 1.62 GiB | 67.3× | OK |
| Pipitbytecode VM | 7 | 1.60 ms | 50.3 ms | 50.7 ms | 282 µs | 592 MiB | 1.00× | OK |
| CPython 3.14bytecode VM | 7 | 498 µs | 125 ms | 126 ms | 476 µs | n/a | 0.31× | OK |
| PyPy 7.3tracing JIT | 7 | 372 µs | 28.9 ms | 33.7 ms | 2.05 ms | n/a | 0.23× | OK |
| tengobytecode VM | 7 | 263 µs | 125 ms | 142 ms | 6.45 ms | 1.69 GiB | 0.16× | OK |
| scriggobytecode VM | 7 | 558 µs | 111 ms | 120 ms | 3.79 ms | 1.69 GiB | 0.35× | OK |
| mvmbytecode VM | 7 | 449 µs | 152 ms | 154 ms | 1.21 ms | 1.69 GiB | 0.28× | OK |
| yaegiAST walker | 7 | 396 µs | 239 ms | 259 ms | 10.1 ms | 1.69 GiB | 0.25× | OK |
Workload & symmetry rules
Workload
Build a slice of 100,000 heterogeneous values mixing *IntVal, *StringVal, *BytesVal, *BoolVal, and *FloatVal. Walk the slice; for each value, dispatch by runtime type:
*IntVal→(v + 1234) & 0xFFFFFFFF*StringVal→fnv1a32(v)*BytesVal→ XOR-fold of bytes*BoolVal→0or1*FloatVal→uint32(v) & 0xFFFFFFFF
XOR every result into a uint32 accumulator.
Symmetry rules
- Go uses a real
switch v := v.(type)block; Python usesisinstance(...)if/elif equivalents. - No virtual method on the values themselves (that would be bench 13).
Why this benchmark exists
Distinct path from virtual dispatch and from generic dispatch. Measures the cost of runtime type discrimination in a hot loop.
Source code
pipit / Go
pipit_source.gonative Go
native_main.goCPython / PyPy
cpython.pytengo
script.tengo