[LRUG] Writing specs for the time-complexity of a method

Tim Cowlishaw tim at timcowlishaw.co.uk
Tue Oct 25 03:13:29 PDT 2011


On Tue, Oct 25, 2011 at 11:08 AM, Mr Jaba <the.jaba at gmail.com> wrote:
> Hey Tim,
>
> Sounds like an interesting idea; but I'm guessing that the difference would
> be negligible between the two implementations for any small set of data, so
> to actually get a difference you could measure reliably you'd need to work
> with large sets of data and thus slow your test suite down.

Yeah, this is exactly the problem - and even then it'd probably be
worth doing several runs and taking the mean, slowing it down further

> I guess my point
> is that you have already tested the functionality of the algorithm, would it
> be worth the added complexity of timing the tests? What's the benefit?

Yep, that'd be my default position too - although then, if I was a
die-hard BDD'er, I'd be able to implement the naive algorithm, then go
home as all my specs passed. I guess I'm more curious about how you
deal with time-complexity constraints under a mega-BDD regime.

Cheers!

Tim



More information about the Chat mailing list