# 06 · dispatch-bench **演示**:20 万次 `if/elseif` 与函数表分派的 `os.clock` 对比。 **运行时**:`lua54`、`luajit`。 **运行**: ```sh .tools/bin/lua54 scripts/run-example.lua examples/06-control-flow-and-truthiness/06-dispatch-bench .tools/bin/lua54 scripts/test-example.lua examples/06-control-flow-and-truthiness/06-dispatch-bench ``` **预期输出**(lua 5.4.9 / macOS arm64): ```text chain_positive=true table_positive=true ``` **看点**:两种写法结果一致;函数表更易扩展,但每次多一次表查找。 **注意**:只断言结果相等,不比较绝对耗时。