Skip to content

Instantly share code, notes, and snippets.

@sonalkr132
Created November 8, 2021 05:18
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 sonalkr132/fd361e4e377f04035e74e6f6c0ac4fd3 to your computer and use it in GitHub Desktop.
Save sonalkr132/fd361e4e377f04035e74e6f6c0ac4fd3 to your computer and use it in GitHub Desktop.
require 'benchmark/ips'
Benchmark.ips do |x|
x.iterations = 10
x.report("just_updated") do
Version.just_updated(50).to_a
end
x.report("just_updated_new") do
Version.just_updated_new(50).to_a
end
x.compare!
end
$ rails runner lib/just_updated_comapre.rb
Warming up --------------------------------------
just_updated 1.000 i/100ms
just_updated_new 1.000 i/100ms
just_updated 1.000 i/100ms
just_updated_new 1.000 i/100ms
just_updated 1.000 i/100ms
just_updated_new 1.000 i/100ms
just_updated 1.000 i/100ms
just_updated_new 1.000 i/100ms
just_updated 1.000 i/100ms
just_updated_new 1.000 i/100ms
just_updated 1.000 i/100ms
just_updated_new 1.000 i/100ms
just_updated 1.000 i/100ms
just_updated_new 1.000 i/100ms
just_updated 1.000 i/100ms
just_updated_new 1.000 i/100ms
just_updated 1.000 i/100ms
just_updated_new 1.000 i/100ms
just_updated 1.000 i/100ms
just_updated_new 1.000 i/100ms
Calculating -------------------------------------
just_updated 1.155 (_ 0.0%) i/s - 6.000 in 5.192876s
just_updated_new 9.744 (_ 0.0%) i/s - 49.000 in 5.028857s
just_updated 1.180 (_ 0.0%) i/s - 6.000 in 5.086182s
just_updated_new 9.751 (_ 0.0%) i/s - 49.000 in 5.025749s
just_updated 1.174 (_ 0.0%) i/s - 6.000 in 5.110814s
just_updated_new 9.781 (_ 0.0%) i/s - 49.000 in 5.010069s
just_updated 1.172 (_ 0.0%) i/s - 6.000 in 5.118410s
just_updated_new 9.658 (_ 0.0%) i/s - 49.000 in 5.078506s
just_updated 1.171 (_ 0.0%) i/s - 6.000 in 5.122628s
just_updated_new 9.759 (_ 0.0%) i/s - 49.000 in 5.020966s
just_updated 1.171 (_ 0.0%) i/s - 6.000 in 5.121990s
just_updated_new 9.762 (_ 0.0%) i/s - 49.000 in 5.019853s
just_updated 1.177 (_ 0.0%) i/s - 6.000 in 5.098674s
just_updated_new 9.770 (_ 0.0%) i/s - 49.000 in 5.015508s
just_updated 1.189 (_ 0.0%) i/s - 6.000 in 5.044222s
just_updated_new 9.784 (_ 0.0%) i/s - 49.000 in 5.008067s
just_updated 1.187 (_ 0.0%) i/s - 6.000 in 5.053813s
just_updated_new 9.779 (_ 0.0%) i/s - 49.000 in 5.010926s
just_updated 1.176 (_ 0.0%) i/s - 6.000 in 5.100921s
just_updated_new 9.759 (_ 0.0%) i/s - 49.000 in 5.021151s
Comparison:
just_updated_new: 9.8 i/s
just_updated: 1.2 i/s - 8.30x (_ 0.00) slower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment