# The CrystalRuby gem through the Crystal lens

**URL:** <https://forum.crystal-lang.org/t/the-crystalruby-gem-through-the-crystal-lens/6832>\
**Category:** Community\
**Created:** [May 9, 2024, 2:31pm UTC](https://forum.crystal-lang.org/t/the-crystalruby-gem-through-the-crystal-lens/6832 "2024-05-09T14:31:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![beta-ziliani](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/beta-ziliani/32/1821_2.png) [@beta-ziliani](https://forum.crystal-lang.org/u/beta-ziliani)\
**Post date:** [May 9, 2024, 2:31pm UTC](https://forum.crystal-lang.org/t/the-crystalruby-gem-through-the-crystal-lens/6832/1 "2024-05-09T14:31:24Z")

</div>

I wrote a little article discussing a recent post on the CrystalRuby gem: [Yes, Ruby is fast, but… - DEV Community](https://dev.to/betaziliani/yes-ruby-is-fast-but-1l49)

---

<div class="post-metadata">

**Author:** ![jgaskins](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/jgaskins/32/2449_2.png) [@jgaskins](https://forum.crystal-lang.org/u/jgaskins)\
**Post date:** [May 10, 2024, 1:07am UTC](https://forum.crystal-lang.org/t/the-crystalruby-gem-through-the-crystal-lens/6832/2 "2024-05-10T01:07:37Z")

</div>

I modded it up to be a bit more visible in feeds — I used to work at the company that runs DEV and managed to get moderator status over the [#crystal](https://dev.to/t/crystal) tag. :-D

One important note, though, because I also ran some benchmarks when I saw John Hawthorn’s post and got a similar result: even with your attempts to avoid LLVM over-optimizing, it’s still happening. When you pass a numeric literal to the method as well as calling `times` on a numeric literal, LLVM might (depending on CPU and LLVM version) optimize it all down to a single instruction. Crystal is incredibly fast, but it’s not “1 million exponential-time `fib(45)`s in 1µs” fast.

---

<div class="post-metadata">

**Author:** ![beta-ziliani](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/beta-ziliani/32/1821_2.png) [@beta-ziliani](https://forum.crystal-lang.org/u/beta-ziliani)\
**Post date:** [May 10, 2024, 3:53pm UTC](https://forum.crystal-lang.org/t/the-crystalruby-gem-through-the-crystal-lens/6832/3 "2024-05-10T15:53:19Z")

</div>

Ah, fair point that I forgot to mention. I originally tested adding a call to `rand` for this particular reason, and I still got a huge boost compared to JITs (and hard to tell how much of that is just the `rand` call):

```auto
  0.001187 0.000076 0.001263 ( 0.001300)

```

---

<div class="post-metadata">

**Author:** ![beta-ziliani](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/beta-ziliani/32/1821_2.png) [@beta-ziliani](https://forum.crystal-lang.org/u/beta-ziliani)\
**Post date:** [May 10, 2024, 3:54pm UTC](https://forum.crystal-lang.org/t/the-crystalruby-gem-through-the-crystal-lens/6832/4 "2024-05-10T15:54:50Z")

</div>

I also tested bigint and oh boy that was painful to watch 😬 something to consider optimizing in the future

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [May 10, 2024, 4:02pm UTC](https://forum.crystal-lang.org/t/the-crystalruby-gem-through-the-crystal-lens/6832/5 "2024-05-10T16:02:15Z")

</div>

Related: [Fibonacci benchmark - The Crystal Programming Language](https://crystal-lang.org/2016/07/15/fibonacci-benchmark/)

---

<div class="post-metadata">

**Author:** ![beta-ziliani](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/beta-ziliani/32/1821_2.png) [@beta-ziliani](https://forum.crystal-lang.org/u/beta-ziliani)\
**Post date:** [May 10, 2024, 4:56pm UTC](https://forum.crystal-lang.org/t/the-crystalruby-gem-through-the-crystal-lens/6832/6 "2024-05-10T16:56:55Z")

</div>

I extended the post with these considerations.
