Home
Testing 1,2,3... - October 30th, 2005 [entries|archive|friends|userinfo]
djberg96

[ website | Sapphire ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| Ruby Home RubyForge RAA comp.lang.ruby Ruby Documentation ]

October 30th, 2005

BenchUnit? [Oct. 30th, 2005|09:36 am]
[mood |awake]

I'm in the process of writing a hefty benchmark suite for Ruby. I'm doing this for several reasons - so we have a baseline to compare minor (or major) releases against each other, heavy iteration testing, checks for pathological slowdowns, and as a way to spot code we could optimize.

One of the things I'm discovering is that I'm constantly having to create a fresh instance of some object, then benchmarking against that object, to make sure I've got a "clean" object that wasn't affected by one of the other benchmarks. Sounds just like the scenario we have in testing, doesn't it? It's also annoying to constantly wrap everything in "MAX.times{ code_to_benchmark }".

It would be nice to have something like this:
class BC_Array < Bench::Unit::BenchCase
   def setup
      @max   = 100000
      @array = [1, "two", nil, true, 3]
   end

   def bench_clear
      @array.clear
   end

   def bench_concat
      @array.concat([1,2,3])
   end   

   def teardown
      @array = nil
   end
end

In this theoretical code, every method that started with "bench_" would be run as a benchmark, iterating "@max" times automatically, getting a new "@array" within each benchmark. I suppose you could create "bench runners" to format output and such as well.

So, who needs a task?
link1 comment|post comment

Note to the M.E. [Oct. 30th, 2005|11:47 am]
If I die of a heart attack before I'm 40, it was the chili cheese fritos.
linkpost comment

navigation
[ viewing | October 30th, 2005 ]
[ go | Previous Day|Next Day ]

Advertisement