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
# Benchmark code an results for: | |
# http://blog.gregspurrier.com/articles/relative-performance-of-symbol-to-proc-in-popular-ruby-implementations | |
require 'benchmark' | |
class Dummy | |
def one | |
1 | |
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
# Example code and benchmark harness for http://blog.gregspurrier.com/articles/arbitrary-reordering-of-ruby-arrays | |
require 'rubygems' | |
require 'rspec' | |
module Enumerable | |
def reorder_by1(order, &key_proc) | |
order.map do |x| | |
find {|obj| key_proc.call(obj) == x} | |
end |
NewerOlder