Skip to content

Instantly share code, notes, and snippets.

@britishtea
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save britishtea/8869118 to your computer and use it in GitHub Desktop.
Save britishtea/8869118 to your computer and use it in GitHub Desktop.
require "benchmark"
require "benchmark/ips"
require "dish"
hash = {
title: "My Title",
authors: [
{ id: 1, name: "Mike Anderson" },
{ id: 2, name: "Well D." }
],
active: false
}
dish = Dish(hash)
Benchmark.ips do |x|
x.report("hash") { hash[:title] }
x.report("dish") { dish.title }
end
$ ruby dish.rb
Calculating -------------------------------------
hash 69367 i/100ms
dish 24472 i/100ms
-------------------------------------------------
hash 3948215.8 (±23.7%) i/s - 16023777 in 4.999657s
dish 538116.3 (±12.0%) i/s - 2642976 in 5.006639s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment