View bin_packing.rb
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 "minitest/autorun" | |
require "benchmark/ips" | |
class CachingPack | |
def self.call(inventory, order) | |
return if inventory.nil? || inventory.empty? | |
return if inventory.inject(:+) < order | |
loop do | |
r = cached_pack(inventory, order) |
View dci_benchmark.rb
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 'rubygems' | |
require 'benchmark/ips' | |
class ExampleClass | |
def foo; 42; end | |
end | |
non_dci_object = ExampleClass.new | |
module ExampleMixin |
View gist:512596
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
class Inspect | |
def self.profile | |
require 'ruby-prof' | |
RubyProf.start | |
result = yield | |
prof_result = RubyProf.stop | |
printer = RubyProf::FlatPrinter.new(prof_result) |