Sha256: 32aeee98788fb5ef705f277360590424f652265a0291890679684a36cd65b425

Contents?: true

Size: 1007 Bytes

Versions: 1

Compression:

Stored size: 1007 Bytes

Contents

require "benchmark_driver"

Benchmark.driver do |x|
  x.prelude <<~RUBY
    require "sin_refinements"
    require "bundler/setup"
    require "with_refinements"

    using WithRefinements

    module M
      refine(String) do
        def goodbye
          -"goodbye"
        end
      end
    end

    module Plain
      refine(String) do
        def world
          -"world"
        end
      end
    end

    using Plain

    class String
      def george
        -"george"
      end
    end
  RUBY

  x.report 'plain monkey patch', %{
    "hello".george
  }

  x.report 'plain refinements', %{
    "hello".world
  }

  x.report 'with_refinements', %{
    with_refinements(M) { "hello".goodbye }
  }

  x.report 'with_refinements_light', %{
    with_refinements_light(M) { "hello".goodbye }
  }

  x.report 'SinRefinements.refining', %{
    SinRefinements.refining(M) { "hello".goodbye }
  }

  x.report 'SinRefinements.light_refining', %{
    SinRefinements.light_refining(M) { "hello".goodbye }
  }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
with_refinements-0.5.0 examples/b.rb