Skip to content

Examples of Ruby code in Crystal and benchmarks to compare

Notifications You must be signed in to change notification settings

marksiemers/ruby-to-crystal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Examples of Ruby code in Crystal and benchmarks to compare

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published