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.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
Gemfile
Gemfile.lock
README.md

README.md

ruby-to-crystal

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

Dependencies

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

Development

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.

Contributing

  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

Contributors