From c2d46ce8b337eb84da903a5e1760cc7f06380284 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Sat, 21 Aug 2010 17:54:59 +0000 Subject: [PATCH] Script to time the overhead of breaking up a problem into many factors (mimics a linear latent-variable model) --- tests/Makefile.am | 2 +- tests/timeFactorOverhead.cpp | 137 +++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 tests/timeFactorOverhead.cpp diff --git a/tests/Makefile.am b/tests/Makefile.am index 401a247a8..17070bcb4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,7 +25,7 @@ check_PROGRAMS += testConstraintOptimizer endif # Timing tests -noinst_PROGRAMS = timeGaussianFactorGraph +noinst_PROGRAMS = timeGaussianFactorGraph timeFactorOverhead #---------------------------------------------------------------------------------------------------- # rules to build unit tests diff --git a/tests/timeFactorOverhead.cpp b/tests/timeFactorOverhead.cpp new file mode 100644 index 000000000..68b215deb --- /dev/null +++ b/tests/timeFactorOverhead.cpp @@ -0,0 +1,137 @@ +/** + * @file timeFactorOverhead.cpp + * @brief Compares times of solving large single-factor graphs with their multi-factor equivalents. + * @author Richard Roberts + * @created Aug 20, 2010 + */ + +#include +#include +#include + +#include +#include +#include + +using namespace gtsam; +using namespace std; + +static boost::variate_generator > rg(boost::mt19937(), boost::uniform_real<>(0.0, 1.0)); + +int main(int argc, char *argv[]) { + + Symbol key('x', 0); + + size_t vardim = 2; + size_t blockdim = 1; + size_t nBlocks = 2000; + + size_t nTrials = 500; + + double blockbuild, blocksolve, combbuild, combsolve; + + cout << "\n1 variable of dimension " << vardim << ", " << + nBlocks << " blocks of dimension " << blockdim << "\n"; + cout << nTrials << " trials\n"; + + ///////////////////////////////////////////////////////////////////////////// + // Timing test with blockwise Gaussian factor graphs + + { + // Build GFG's + cout << "Building blockwise Gaussian factor graphs... "; + cout.flush(); + boost::timer timer; + timer.restart(); + vector blockGfgs; + blockGfgs.reserve(nTrials); + for(size_t trial=0; trial combGfgs; + for(size_t trial=0; trial