Download Links

Simulate 3D | SBW (Win32) | Bifurcation Discovery | FluxBalance

Saturday, April 27, 2013

Ninja to the rescue

Don't you hate all these long compile times? I've head of Ninja a long time ago, but never gave it much thought. In case you don't feel like following the page, Ninja is a replacement for make / nmake. So today I gave it a try:

Installation

Couldn't be simpler. I cloned the git repository, opened a VS command line, called bootstrap.py with python 2.7, and added the directory to the path.

Configuring libSBML

I figured libSBML makes for a great test project, at least on my machine a build of it with tests takes forever. So I configured a new build of libsbml, release, static runtime, with tests. Thus the configuration line is:

cmake -G Ninja -DWITH_CHECK=ON -DWITH_STATIC_RUNTIME=ON -DLIBSBML_DEPENDENCY_DIR=..\..\vs11_dependencies_32_static-release ..\..

and the build is ready to go. To collect timing information, i run using time:

\cygwin\bin\time.exe ninja

And *drumroll*, time reported: 0.00user 0.00system 2:29.59elapsed 0%CPU. If you know Windows C++ builds (on non SSD drives), you know they take forever, so having all these projects build in two and a half minutes is amazing.

counter example

Just so you know, here the counter example, of using NMake as distributed by VS11. Here the configure line is:

cmake -G "NMake Makefiles"  -DWITH_CHECK=ON -DWITH_STATIC_RUNTIME=ON -DLIBSBML_DEPENDENCY_DIR=..\..\vs11_dependencies_32_static-release -DCMAKE_BUILD_TYPE=Release ..\..

running timed build again leaves gives us: 0.00user 0.00system 8:31.14elapsed 0%CPU. A whole 6 minutes more!

More data

So I couldn’t stop there, a compilation of libSBML on OSX  took (again with tests) 1m55.769 (vs. 4m4.568 for the regular make, and 2m2.698 for make –j 4). With universal binaries (i386 + x86_64) that time doubles as expected. Not too much of a difference. But this is made up by the fact that the output of ninja displays all critical things like warnings an errors nicely.

Today I used ninja for COPASI. Just as example: CopasiSE + CopasiUI + java bindings builds in just 4 minutes, 28! As compared to the 24m28 that nmake was using.

It seems obvious that using Ninja definitely saves a bunch of time, especially when compiling on Windows. The next thing to try is to use it as external build tool in VS!

No comments: