Sha256: 3a8a58893c98fbb6b8d829e324cdc09da9d7b9ed62644fa272e25db776ea3dc3

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require "bundler/gem_tasks"
require "rake/testtask"
require "rake/extensiontask"

#  Test
#-----------------------------------------------
Rake::TestTask.new(:test) do |t|
  t.libs << "test"
end

#  Compile C extension
#-----------------------------------------------
Rake::ExtensionTask.new("rubype") do |ext|
  ext.lib_dir = "lib/rubype"
end

task :compile_and_test do
  Rake::Task['compile'].invoke
  Rake::Task['test'].invoke
end

#  Benchmark
#-----------------------------------------------
desc "Compare with pure ruby"
task :benchmark do
  require "benchmark/ips"
  require "rubype"
  require "rubype/version"

  puts "ruby version: #{RUBY_VERSION}"
  class PureClass
    def sum(x, y)
      x + y
    end
  end
  pure_instance = PureClass.new

  puts "rubype version: #{Rubype::VERSION}"
  class RubypeClass
    def sum(x, y)
      x + y
    end
    typesig :sum, [Numeric, Numeric] => Numeric
  end
  rubype_instance = RubypeClass.new

  Benchmark.ips do |x|
    x.report('Pure Ruby') { pure_instance.sum(4, 2) }
    x.report('Rubype') { rubype_instance.sum(4, 2) }

    x.compare!
  end
end
task bm: :benchmark


task default: :compile_and_test

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubype-0.3.1 Rakefile
rubype-0.3.0 Rakefile