In this article, we'll examine the performance difference between approaches for raindrops
in Crystal.
The approaches page lists three approaches to this exercise:
Benchmarks
To benchmark the approaches, we wrote a small benchmark application using the built-in Benchmark
module.
These tests were run in WSL2, using Crystal 1.11.2 (llvm 15).
Your system results may vary.
RaindropsConditional
0.000005 0.000000 0.000005 ( 0.000003)
RaindropsDataDriven
0.000003 0.000000 0.000003 ( 0.000003)
Conclusion
It is hard to make a conclusion from these results, as the difference is so small. However, the rules approach is slightly faster than the conditionals approach, but the difference is so small that it is hard to make a definitive conclusion.
11th Dec 2024
·
Found it useful?