Sha256: 0191df36b979654b7d5983f28d048a6eb5eeb5c7c454465017786048b599ef6c

Contents?: true

Size: 482 Bytes

Versions: 13

Compression:

Stored size: 482 Bytes

Contents

#!/usr/bin/env ruby

require 'benchmark'

class Thing
  attr_reader :part

  def initialize(part)
    @part = part
  end
end

prng = Random.new
v_max = 1 << 31
ary = []
1000.times do
  ary << Thing.new(rand(v_max))
end

Benchmark.bmbm do |x|
  x.report("sort!") do
    1000.times do
      ary2 = ary.dup
      ary2.sort! { |a, b| a.part <=> b.part }
    end
  end
  x.report("sort_by!") do
    1000.times do
      ary2 = ary.dup
      ary2.sort_by! { |i| i.part }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bio-maf-1.0.1-java benchmarks/sort_bench
bio-maf-1.0.1 benchmarks/sort_bench
bio-maf-1.0.0-java benchmarks/sort_bench
bio-maf-1.0.0 benchmarks/sort_bench
bio-maf-0.3.2-java benchmarks/sort_bench
bio-maf-0.3.2 benchmarks/sort_bench
bio-maf-0.3.1 benchmarks/sort_bench
bio-maf-0.3.0-java benchmarks/sort_bench
bio-maf-0.3.0 benchmarks/sort_bench
bio-maf-0.2.0-java benchmarks/sort_bench
bio-maf-0.2.0 benchmarks/sort_bench
bio-maf-0.1.0 benchmarks/sort_bench
bio-maf-0.1.0-java benchmarks/sort_bench