Skip to content

Instantly share code, notes, and snippets.

@Watson1978
Created August 20, 2017 12:03
Show Gist options
  • Save Watson1978/826151f7891bd0f15dbdebcbe32a2628 to your computer and use it in GitHub Desktop.
Save Watson1978/826151f7891bd0f15dbdebcbe32a2628 to your computer and use it in GitHub Desktop.
require 'benchmark/ips'
Benchmark.ips do |x|
x.report "Hash" do |loop|
{foo: 42, bar: "hello", baz: "test"}
end
end
@Watson1978
Copy link
Author

Watson1978 commented Aug 20, 2017

Before

$ ./miniruby -v -Ilib -I../benchmark-ips/lib  ~/tmp/bench.rb
ruby 2.5.0dev (2017-08-20 trunk 59394) [x86_64-linux]
Warming up --------------------------------------
                Hash    98.244k i/100ms
Calculating -------------------------------------
                Hash    113.432B (±11.9%) i/s -    358.198B in   3.776462s

After

$ ./miniruby -v -Ilib -I../benchmark-ips/lib  ~/tmp/bench.rb
ruby 2.5.0dev (2017-08-20 trunk 59394) [x86_64-linux]
Warming up --------------------------------------
                Hash   122.583k i/100ms
Calculating -------------------------------------
                Hash    183.803B (±20.1%) i/s -    496.602B in   3.469529s

To be continued to RubyKaigi 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment