From: "ara.t.howard" Date: 2007-07-08T02:35:18+09:00 Subject: Re: flatulent-0.0.3 On Jul 7, 2007, at 11:25 AM, Chris Carter wrote: > Ara, > That is because you set defl and flat inside a block, without setting > the variables to nil before the block is executed, so they stay > existing for the actual decode stage. > ?? # defl = html = code = nil ### irrelevant pairs = Array.new(200) GC.disable i = 0 begin Benchmark.bm(13) do |x| i += 1 defl = html = code = nil ### irrelevant x.report("generate:") { flat = Flatulent.new; html = flat.form; code = flat.string } x.report("setup:") { defl = Deflatulent.new } x.report("break:") { raise "failed on attempt #{ i }" unless defl.deflatulent(html) == code } x.report("generate 200:") { 200.times{|index| flat = Flatulent.new; pairs[index] = [flat.form,flat.string] } } x.report("break 200:") { pairs.map{|(html,code)| raise unless defl.deflatulent(html) == code } } end ensure puts "Flatulent.version : #{ Flatulent.version }" end it fails on the very first attempt: cfp:~ > ruby a.rb user system total real generate: 0.140000 0.020000 0.170000 ( 0.179983) setup: 0.020000 0.000000 0.020000 ( 0.022315) break: Flatulent.version : 0.0.4 a.rb:64: failed on attempt 1 (RuntimeError) from /opt/local/lib/ruby/1.8/benchmark.rb:293:in `measure' from /opt/local/lib/ruby/1.8/benchmark.rb:377:in `report' from a.rb:64 from /opt/local/lib/ruby/1.8/benchmark.rb:177:in `benchmark' from /opt/local/lib/ruby/1.8/benchmark.rb:207:in `bm' from a.rb:59 cheers. -a -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama