Examples of Ruby code in Crystal and benchmarks to compare
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



Examples of ruby code converted to crystal and benchmarks to show the speed increase with compiled crystal code.


Both Ruby and Crystal need to be installed on your system. If they aren't already, follow the installation guide for Ruby and the installation guide for Crystal

If you already have Ruby and you are using Mac OS X with homebrew, install Crystal using:

brew install crystal-lang

Installation & Usage

  1. Clone the repo
git clone git@github.com:marksiemers/ruby-to-crystal.git
# OR
git clone https://github.com/marksiemers/ruby-to-crystal.git
  1. Choose an example and cd into that directory
# for leap-year
cd src/leap-year
  1. Run the ruby example
ruby leap_year.rb
  1. Run the crystal example
crystal leap_year.cr
  1. Run the ruby benchmark
ruby leap_year_bench.rb
  1. Compile and run the crystal benchmark
crystal leap_year_bench.cr --release
  1. Pledge your undying allegiance to crystal


If you want to add an example, create a folder that contains these files at a minimum:

  • {example}.cr
  • {example}.rb
  • {example}_bench.cr
  • {example}_bench.rb

Additionally, it may be helpful to provide an {example}.sh that will execute the example in both languages and report the benchmark results.


  1. Fork it ( https://github.com/marksiemers/ruby-to-crystal/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request