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
require "benchmark/ips" | |
require_relative "./method_overloading" | |
class Foo | |
include MethodOverloading | |
def call(number) | |
"foo #{number}" | |
end | |
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
# frozen_string_literal: true | |
Thread.current[:request_id] = 'abc123' | |
puts "main thread: #{Thread.current[:request_id]}" | |
Thread.new do | |
puts "inner thread: #{Thread.current[:request_id]}" | |
end.join |
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 "pathname" | |
require "memory_profiler" | |
class Env | |
def load!(*) | |
end | |
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
#!/usr/bin/env ruby | |
require "benchmark/ips" | |
require "set" | |
INPUT = 100.times.map { "my-test-string" }.freeze | |
Benchmark.ips do |x| | |
x.report("Array#uniq") { INPUT.uniq } | |
x.report("Set#to_a") { Set.new(INPUT).to_a } |
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 | |
source "https://rubygems.org" | |
gem "rack" | |
gem "puma" | |
gem "guard-puma" |
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 | |
source "https://rubygems.org" | |
gem "dry-view", git: "https://github.com/dry-rb/dry-view.git", branch: "erb-support" | |
gem "erbse" |
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
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require "benchmark/ips" | |
def validate | |
[false, "not valid"] | |
end | |
Benchmark.ips do |x| |
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
#!/usr/bin/env ruby | |
require 'benchmark/ips' | |
require 'bundler/setup' | |
require 'dnsimple' | |
account_id = 1010 | |
zone_id = 100 | |
record_id = 999 | |
Benchmark.ips do |x| |
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
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require "benchmark/ips" | |
require "securerandom" | |
Benchmark.ips do |x| | |
x.report("hex(16)") { SecureRandom.hex(16) } | |
x.report("uuid") { SecureRandom.uuid } | |
x.compare! |
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
#!/usr/bin/env ruby | |
require 'benchmark/ips' | |
require 'set' | |
SET = (4..16).to_set.freeze | |
HASH = SET.each_with_object({}) { |n, ret| ret[n] = true }.freeze | |
Benchmark.ips do |x| | |
x.report('set') { SET.include?(16) } | |
x.report('hash') { HASH.key?(16) } |