Skip to content

Instantly share code, notes, and snippets.

@blackxored
Created January 5, 2011 15:38
Show Gist options
  • Save blackxored/766468 to your computer and use it in GitHub Desktop.
Save blackxored/766468 to your computer and use it in GitHub Desktop.
class String
def method_missing(name, *args, &block)
name == :ghost_capitalize ? capitalize : super
end
end
require 'benchmark'
Benchmark.bmbm do |b|
b.report "Normal method" do
1_000_000.times { "abc".capitalize }
end
b.report "Ghost method" do
1_000_000.times { "abc".ghost_capitalize }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment