Igor's Blog

"... no matter what they tell you, it's always a people problem!"

Monday, May 29, 2006

How do you keep the build time low?

I was reading: http://jroller.com/page/peter_pilgrim?entry=my_javaone_2006_conference_second1

where Rod Johnson was quoted:
“It is possible to write unit test for applications in J2EE that run under five minutes. If your unit test take place longer than this, then it is wrong.”


I little more relax time is stated in Martin Fowler's Continuous Integration article:
“For most projects, however, the XP guideline of a ten minute build is perfectly within reason. Most of our modern projects achieve this. It's worth putting in concentrated effort to make it happen, because every minute you reduce off the build time is a minute saved for each developer every time they commit. Since CI demands frequent commits, this adds up to a lot of time. “

I completely agree with both of them although I would prefer the five minute constrain. Slow builds could have huge impact on the productivity of an Agile/XP team. Some of the reasons for slow build times are if we use database fixtures (as the accepted practices in RoR) or if we don’t bother to use stabs/mocks when appropriate in our test. All of that could be disregarded by many as unnecessary complication but from my previous experience on various projects using db fixtures or not using stabs/mocks have been an issue at some point or another.

An example is the fact that the build for my current project that has been continuing for the last year and a half, on average 6-8 developers, more that 1000 classes, about 100 domain objects with up to 83% unit test coverage (at times :-)) is taking just a little more that 4 min and about 1 min of that is xdoclet generation. The real time is 3 min!!! It is not even a pure unit test build. Our build includes testing the persistence for all domain objects with the database that would be in production as well as the instantiation of Spring IoC container inside the unit tests.

In the beginning we didn’t use stubs/mocks and everything was “freely” accessing the database. After the second month of the project, the build (probably about 20-25% of the current size of the project) was taking already more than 4 min! I have seen/heard about many projects where the unit test build is taking from 30 -1.30 min. I strongly believe that built times like that are unacceptable for an XP team.

I haven’t had the chance to use RoR on something more than a personal learning projects and I wonder how much time is a build taking on an average enterprise project using RoR or how do you overcome this potential problem in RoR projects?
|| Igor, Monday, May 29, 2006

3 Comments:

Here's a quick paste of the build from the ruby/rails/dsl project we are currently finishing up for a major bank.

Started
.........................................................................................................................................................................
Finished in 1.852947 seconds.

169 tests, 155 assertions, 0 failures, 0 errors

Started
...............................................................
Finished in 3.275821 seconds.

63 tests, 90 assertions, 0 failures, 0 errors

Test coverage is around 85%.

I personally do not like fixtures, but some of the other team members do use them in their tests.

The db we are using locally is postgres.

Skipping the 'compile' step is quite nice. Though I could live with 5 minute builds, I much prefer 5 second builds. ;)
Anonymous Anonymous, at May 29, 2006 4:49 PM  
Point taken, Jay. Thanks for the comment.
Blogger Igor, at May 29, 2006 5:20 PM  
Jay beat me to it!
Blogger Obie, at May 29, 2006 10:15 PM  

Add a comment