Skip to content

Conversation

@antiguru
Copy link
Member

Summary

  • Add comprehensive benchmarks for scalar function evaluation using the bencher crate
  • Covers ~380 benchmark cases across binary (191), unary (213), and variadic (29) functions
  • Multi-input macros (bench_*_multi!) evaluate diverse parameter values per iteration for math-sensitive functions (sqrt, trig, log, div, power) to avoid misleading results from "easy" inputs

Key findings from initial run

  • Eval dispatch floor: ~20 ns (irreducible cost of literal extraction + enum match + trait dispatch)
  • Numeric arithmetic is dramatically slower: numeric sqrt is ~280x slower than float64, numeric log is ~1000x slower
  • Regex compilation per call: variadic RegexpMatch ~47 us due to per-call regex compilation
  • ToChar: ~81 us due to format string parsing per call

Test plan

  • cargo bench -p mz-expr --bench bench_binary — 191 benchmarks pass
  • cargo bench -p mz-expr --bench bench_unary — 213 benchmarks pass
  • cargo bench -p mz-expr --bench bench_variadic — 29 benchmarks pass

🤖 Generated with Claude Code

…funcs

Add comprehensive benchmarks using the `bencher` crate covering the full
eval path (MirScalarExpr::Literal → datum extraction → function call →
result). Multi-input macros (`bench_*_multi!`) evaluate diverse parameter
values per iteration for math-sensitive functions (sqrt, trig, log, div,
power) to avoid misleading results from "easy" inputs like perfect squares.

- bench_binary.rs: ~180 benchmarks (arithmetic, bitwise, comparison, string,
  pattern matching, encoding, digest, datetime)
- bench_unary.rs: ~170 benchmarks (boolean, arithmetic, trig, casts, string,
  hash, datetime)
- bench_variadic.rs: 29 benchmarks (logic, string, JSON, HMAC, datetime)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant