When running 'annotate all lines' in textmate with a file I had been working on, This File. It froze textmate for a good 10 mins while it chewed on that problem. After realizing it wasn't going finish I killed it and began to investigate. I was able to narrow it down to the benchmarks, as commenting them out had it working fine.
It might be helpful to also note that it hangs when trying the process from the command line as well, so I don't think there is any direction connection to text mate.
This is the ruby process after running for a few minutes.
I'm not sure if this is of any importance, but this is what happens to my source file after I kill the process.
# Standard coin changer
begin;def changer(change)
$SiB.record_result(8, ($SiB.record_result(4, ([25,10,5,1])).flat_map do |coin|
$SiB.record_result(5, (remaining = (change / coin)))
$SiB.record_result(6, (change -= (remaining * coin)))
$SiB.record_result(7, ([coin] * remaining))
end))
end
$SiB.record_result(10, (changer(99)))
# Coin changer with reduced assignment operations
def ch(amt)
$SiB.record_result(19, ($SiB.record_result(14, ([25,10,5,1])).flat_map do |coin|
$SiB.record_result(18, ([coin] * ($SiB.record_result(15, (amt / coin)))
.tap { |rem|
$SiB.record_result(17, (amt -= rem * coin))
}))
end))
end
$SiB.record_result(21, (ch(99)))
# "Golfed" coin changer
def z(a)$SiB.record_result(24, ([25,10,5,1].flat_map{|c|[c]*(a/c).tap{|x|a-=x*c}}))end
$SiB.record_result(25, (z(99)))
# "No Assignment" coin changer
def chr(amt)
$SiB.record_result(35, ($SiB.record_result(31, ($SiB.record_result(30, ($SiB.record_result(29, ([25,10,5,1].map { |x| amt / x }))
.zip([25,10,5,1])))
.flat_map{|quot, coin| [coin] * quot }))
.inject([]) { |acc, n|
$SiB.record_result(33, (acc << n if acc.inject(n,:+) <= amt))
$SiB.record_result(34, (acc))
}))
end
$SiB.record_result(37, (chr(99)))
$SiB.record_result(74, (if $SiB.record_result(39, ($0 !~ /rspec/))
$SiB.record_result(40, (require 'benchmark'))
$SiB.record_result(41, (GC.disable))
$SiB.record_result(47, ($SiB.record_result(42, (Benchmark)).bm(10) do |x|
$SiB.record_result(43, (x.report('changer') { 1000.times { (0..100).each { |c| changer(c) }}}))
$SiB.record_result(44, (x.report('ch') { 1000.times { (0..100).each { |c| ch(c) }}}))
$SiB.record_result(45, (x.report('z') { 1000.times { (0..100).each { |c| z(c) }}}))
$SiB.record_result(46, (x.report('chr') { 1000.times { (0..100).each { |c| chr(c) }}}))
end))
else
$SiB.record_result(73, (describe "provides correct change" do
$SiB.record_result(72, ($SiB.record_result(57, ([
$SiB.record_result(51, ([100, [25,25,25,25]])),
$SiB.record_result(52, ([75, [25,25,25]])),
$SiB.record_result(53, ([50, [25,25]])),
$SiB.record_result(54, ([25, [25]])),
$SiB.record_result(55, ([65, [25, 25, 10, 5]])),
$SiB.record_result(56, ([37, [25,10,1,1]]))
])).each do |amount, change|
$SiB.record_result(71, (context "for #{amount}" do
$SiB.record_result(61, (it "changer: #{change}" do
$SiB.record_result(60, (changer(amount).should == change))
end))
$SiB.record_result(64, (it "chr: #{change}" do
$SiB.record_result(63, (chr(amount).should == change))
end))
$SiB.record_result(67, (it "ch: #{change}" do
$SiB.record_result(66, (ch(amount).should == change))
end))
$SiB.record_result(70, (it "z: #{change}" do
$SiB.record_result(69, (z(amount).should == change))
end))
end))
end))
end))
end));rescue Exception;line_number = $!.backtrace.grep(/#{__FILE__}/).first[/:\d+/][1..-1].to_i;$SiB.record_exception line_number, $!;$SiB.exitstatus = 1;$SiB.exitstatus = $!.status if $!.kind_of? SystemExit;end