From 51eab1068fa9831edb854f685472d6611f848e69 Mon Sep 17 00:00:00 2001 From: dellaert Date: Mon, 6 Oct 2014 13:57:37 +0200 Subject: [PATCH] Time the most common SFM expression --- .cproject | 106 +++++++++--------- .../timing/timeOneCameraExpression.cpp | 66 +++++++++++ 2 files changed, 118 insertions(+), 54 deletions(-) create mode 100644 gtsam_unstable/timing/timeOneCameraExpression.cpp diff --git a/.cproject b/.cproject index 80dbe0a0b..79ad1df26 100644 --- a/.cproject +++ b/.cproject @@ -600,7 +600,6 @@ make - tests/testBayesTree.run true false @@ -608,7 +607,6 @@ make - testBinaryBayesNet.run true false @@ -656,7 +654,6 @@ make - testSymbolicBayesNet.run true false @@ -664,7 +661,6 @@ make - tests/testSymbolicFactor.run true false @@ -672,7 +668,6 @@ make - testSymbolicFactorGraph.run true false @@ -688,7 +683,6 @@ make - tests/testBayesTree true false @@ -910,6 +904,14 @@ true true + + make + -j5 + timeOneCameraExpression.run + true + true + true + make -j5 @@ -1032,7 +1034,6 @@ make - testErrors.run true false @@ -1262,46 +1263,6 @@ true true - - make - -j5 - testBTree.run - true - true - true - - - make - -j5 - testDSF.run - true - true - true - - - make - -j5 - testDSFMap.run - true - true - true - - - make - -j5 - testDSFVector.run - true - true - true - - - make - -j5 - testFixedVector.run - true - true - true - make -j2 @@ -1384,6 +1345,7 @@ make + testSimulated2DOriented.run true false @@ -1423,6 +1385,7 @@ make + testSimulated2D.run true false @@ -1430,6 +1393,7 @@ make + testSimulated3D.run true false @@ -1443,6 +1407,46 @@ true true + + make + -j5 + testBTree.run + true + true + true + + + make + -j5 + testDSF.run + true + true + true + + + make + -j5 + testDSFMap.run + true + true + true + + + make + -j5 + testDSFVector.run + true + true + true + + + make + -j5 + testFixedVector.run + true + true + true + make -j5 @@ -1700,7 +1704,6 @@ cpack - -G DEB true false @@ -1708,7 +1711,6 @@ cpack - -G RPM true false @@ -1716,7 +1718,6 @@ cpack - -G TGZ true false @@ -1724,7 +1725,6 @@ cpack - --config CPackSourceConfig.cmake true false @@ -2451,7 +2451,6 @@ make - testGraph.run true false @@ -2459,7 +2458,6 @@ make - testJunctionTree.run true false @@ -2467,7 +2465,6 @@ make - testSymbolicBayesNetB.run true false @@ -2955,6 +2952,7 @@ make + tests/testGaussianISAM2 true false diff --git a/gtsam_unstable/timing/timeOneCameraExpression.cpp b/gtsam_unstable/timing/timeOneCameraExpression.cpp new file mode 100644 index 000000000..a76200812 --- /dev/null +++ b/gtsam_unstable/timing/timeOneCameraExpression.cpp @@ -0,0 +1,66 @@ +/* ---------------------------------------------------------------------------- + + * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * Atlanta, Georgia 30332-0415 + * All Rights Reserved + * Authors: Frank Dellaert, et al. (see THANKS for the full author list) + + * See LICENSE for the license information + + * -------------------------------------------------------------------------- */ + +/** + * @file timeOneCameraExpression.cpp + * @brief time CalibratedCamera derivatives + * @author Frank Dellaert + * @date October 3, 2014 + */ + +#include +#include + +#include +#include +#include // std::setprecision +using namespace std; +using namespace gtsam; + +static const int n = 500000; + +void time(const NonlinearFactor& f, const Values& values) { + long timeLog = clock(); + GaussianFactor::shared_ptr gf; + for (int i = 0; i < n; i++) + gf = f.linearize(values); + long timeLog2 = clock(); + double seconds = (double) (timeLog2 - timeLog) / CLOCKS_PER_SEC; + cout << setprecision(3); + cout << ((double) seconds * 1000000 / n) << " musecs/call" << endl; +} + +int main() { + + // Create leaves + Pose3_ x(1); + Point3_ p(2); + Cal3_S2_ K(3); + + // Some parameters needed + Point2 z(-17, 30); + SharedNoiseModel model = noiseModel::Unit::Create(2); + + // Create values + Values values; + values.insert(1, Pose3()); + values.insert(2, Point3(0, 0, 1)); + values.insert(3, Cal3_S2()); + + // BADFactor + // Oct 3, 2014, Macbook Air + // 20.3 musecs/call + BADFactor newFactor2(model, z, + uncalibrate(K, project(transform_to(x, p)))); + time(newFactor2, values); + + return 0; +}