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
- Clone the repo
git clone git@github.com:marksiemers/ruby-to-crystal.git
# OR
git clone https://github.com/marksiemers/ruby-to-crystal.git
- Choose an example and cd into that directory
# for leap-year
cd src/leap-year
- Run the ruby example
ruby leap_year.rb
- Run the crystal example
crystal leap_year.cr
- Run the ruby benchmark
ruby leap_year_bench.rb
- Compile and run the crystal benchmark
crystal leap_year_bench.cr --release
- 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.
- Fork it ( https://github.com/marksiemers/ruby-to-crystal/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- marksiemers Mark Siemers - creator, maintainer