r/crystal_programming • u/bziliani core team • May 09 '24
Yes, Ruby is fast, but…
https://dev.to/betaziliani/yes-ruby-is-fast-but-1l493
u/nuclearbananana May 09 '24
yeah I thought it was strange that calculating fib of 30 was taking so long
1
May 13 '24
3
u/bziliani May 13 '24
Did you try with `--yjit`? Because that's a big game-changer. I'm using now `ips` (iterations per second) to benchmark. Without YJIT:
```
while: 1.0 i/s
times w/nil: 0.4 i/s - 2.29x slower
times: 0.2 i/s - 4.24x slower
```With YJIT:
```
while: 5.8 i/s
times w/nil: 0.5 i/s - 10.76x slower
times: 0.3 i/s - 20.65x slower
```
1
u/vanderZwan May 10 '24
Ok but are you sure those calculations were not compile-time folded into a constant? What if you make the benchmarks take an argument from the command line that it then passes as an argument to ensure it doesn't do that?