buzz-language / buzz

👨‍🚀 buzz, A small/lightweight statically typed scripting language
https://buzz-lang.dev
MIT License
1.15k stars 31 forks source link

feat(obj): Store properties and methods in a slice rather than a hashmap #301

Closed giann closed 2 weeks ago

giann commented 2 weeks ago

closes https://github.com/buzz-language/buzz/issues/90

We never needed to known the property name at runtime, this is an artifact of the 'Crafting Interpreters' heritage.

This results in a performance boost of about 40% on some benches:

Before:

→ hyperfine --warmup 10 'buzz tests/bench/001-btree.buzz 15 Benchmark 1: buzz tests/bench/001-btree.buzz 15
  Time (mean ± σ):      1.221 s ±  0.022 s    [User: 1.028 s, System: 0.174 s]
  Range (min … max):    1.195 s …  1.271 s    10 runs

After:

→ hyperfine --warmup 10 'buzz tests/bench/001-btree.buzz 15 Benchmark 1: buzz tests/bench/001-btree.buzz 15
  Time (mean ± σ):     795.5 ms ±   7.7 ms    [User: 725.1 ms, System: 62.9 ms]
  Range (min … max):   785.3 ms … 811.7 ms    10 runs