-
-
Save k0kubun/e3da77cae2c132badd386c96f2de5768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'benchmark/ips' | |
Benchmark.ips do |x| | |
x.report('+@') { +"" } | |
x.report('dup') { "".dup } | |
x.compare! | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Warming up -------------------------------------- | |
+@ 436.074k i/100ms | |
dup 292.061k i/100ms | |
Calculating ------------------------------------- | |
+@ 11.490M (± 1.9%) i/s - 57.562M in 5.011607s | |
dup 5.121M (± 1.7%) i/s - 25.701M in 5.020415s | |
Comparison: | |
+@: 11490470.9 i/s | |
dup: 5121009.0 i/s - 2.24x slower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment