/rustby

🦀rustby🐝 - Build with Ruby - Sting with Rust

Primary LanguageRubyMIT LicenseMIT

🦀rustby🐝

💎 Ruby containing Rust 🦀 (thx. to rutie)

Ruby for Development -> Rust for Speed

intro

  • Build in Ruby
    • maintain all functionality in Ruby
  • Optimize in Rust
    • translate performance sensitive operations into Rust

    • compare Ruby and Rust performance using Benchmarker

      benchmark

  • Fallback on Ruby
    • worst case, it's Ruby

    • wrap your Rust code in a default Ruby implimentation using Fallbacker

      fallback

to run:

  • tour
    • rake main
    • rake primes:demo:benchmark {limit} {count}
    • rake primes:demo:fallback {limit} {count}
  • compute primes
    • rake primes:ruby {limit}
    • rake primes:rust {limit}
  • run tests
    • rake spec:run
      • runs rspec and cargo test
      • builds Rust code before running rspec

Primes

  • 🦀rustby🐝 made use of Primes as the example module around which to build
  • it contains two modules to compute primes
  • args
    • {limit} - 💎Integer, 🦀u64
      • compute all primes less than or equal to
      • increase to stress test memory usage
    • {count} - 💎Integer, 🦀u64
      • run the computation this many times
      • increase to stress test computation speed
    • {alg_str} - 💎String
      • select algorithm for computation
      • can be:
        • sieve_of_atkin, soa, s
        • naive, n
demo 🦀rustby🐝 using primes
  • rake primes:demo:benchmark
  • rake primes:demo:fallback
compute using 💎ruby
  • rake primes:ruby {limit} {alg_str}
  • rake primes:ruby:sieve_of_atkin {limit}
  • rake primes:ruby:naive {limit}
compute using 🦀rust
  • rake primes:rust {limit} {alg_str}
  • rake primes:rust:sieve_of_atkin {limit}
  • rake primes:rust:naive {limit}
benchmark performance: 💎ruby vs. 🦀rust
  • rake primes:benchmark {limit} {count}
  • rake primes:benchmark:sieve_of_atkin {limit} {count}
  • rake primes:benchmark:naive {limit} {count}

License

The gem is available as open source under the terms of the MIT License.