Created
August 28, 2021 12:13
-
-
Save postmodern/297bff869107e387b47a795e7c0c2733 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'benchmark' | |
require 'socket' | |
Benchmark.bm(20) do |b| | |
n = 10_000_000 | |
def positional_args(one,two,three,four,five) | |
end | |
b.report('position arguments') do | |
n.times do | |
positional_args(1,2,3,4,5) | |
end | |
end | |
def keyword_args(one: , two: , three: , four: , five: ) | |
end | |
b.report('keyword args') do | |
n.times do | |
keyword_args(one: 1, two: 2, three: 3, four: 4, five: 5) | |
end | |
end | |
end |
This file contains hidden or 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
user system total real | |
position arguments 0.787944 0.000821 0.788765 ( 0.797133) | |
keyword args 1.091629 0.000020 1.091649 ( 1.096063) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment