Skip to content

Instantly share code, notes, and snippets.

@matugm
Created November 15, 2018 00:11
Show Gist options
  • Save matugm/dfec31607bf8aaa4a97b18a386e4ef5e to your computer and use it in GitHub Desktop.
Save matugm/dfec31607bf8aaa4a97b18a386e4ef5e to your computer and use it in GitHub Desktop.

Revisions

  1. matugm created this gist Nov 15, 2018.
    19 changes: 19 additions & 0 deletions hash-benchmark.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    require 'benchmark'

    N = 1_000_000

    Benchmark.bm(10) { |x|
    0.step(to: 16) { |size|
    data = (1..size).zip(Array.new(size))

    x.report(size) {
    i = 0

    while i < N
    Hash[data]

    i += 1
    end
    }
    }
    }