Sha256: 1ebd94b0f76fc7adba267ed10596b3ed3ef0c3c8ee0fcd68df86734c44905136

Contents?: true

Size: 1.47 KB

Versions: 10

Compression:

Stored size: 1.47 KB

Contents

require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

task :default => :spec

task :benchmark do
  require 'konstructor'
  require 'benchmark'

  n = 10000

  Benchmark.bm(30) do |x|
    x.report('def:') do
      n.times do
        Class.new do
          def one; end
          def two; end
          def three; end
          def four; end
          def five; end
        end
      end
    end
    x.report('attr_accessor:') do
      n.times do
        Class.new do
          attr_accessor :one, :two, :three, :four, :five
        end
      end
    end
    x.report('konstructor after:') do
      n.times do
        Class.new do
          def one; end
          def two; end
          def three; end
          def four; end
          def five; end

          konstructor :one, :two, :three, :four, :five
        end
      end
    end
    x.report('konstructor before:') do
      n.times do
        Class.new do
          konstructor :one, :two, :three, :four, :five

          def one; end
          def two; end
          def three; end
          def four; end
          def five; end
        end
      end
    end
    x.report('konstructor nameless:') do
      n.times do
        Class.new do
          konstructor
          def one; end
          konstructor
          def two; end
          konstructor
          def three; end
          konstructor
          def four; end
          konstructor
          def five; end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
konstructor-1.0.1 Rakefile
konstructor-1.0.0 Rakefile
konstructor-0.4.7 Rakefile
konstructor-0.4.6 Rakefile
konstructor-0.4.5 Rakefile
konstructor-0.4.4 Rakefile
konstructor-0.4.3 Rakefile
konstructor-0.4.2 Rakefile
konstructor-0.4.1 Rakefile
konstructor-0.4.0 Rakefile