timing VectorConfig to speed up iterative

release/4.3a0
Frank Dellaert 2010-01-29 13:57:45 +00:00
parent eb88a149a1
commit 65bc90bf15
3 changed files with 599 additions and 531 deletions

View File

@ -469,6 +469,7 @@
</target>
<target name="testBayesTree.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testBayesTree.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -476,7 +477,6 @@
</target>
<target name="testSymbolicBayesNet.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testSymbolicBayesNet.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -484,6 +484,7 @@
</target>
<target name="testSymbolicFactorGraph.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testSymbolicFactorGraph.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -707,6 +708,7 @@
</target>
<target name="testGraph.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testGraph.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -762,7 +764,6 @@
</target>
<target name="testSimulated2D.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testSimulated2D.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -784,6 +785,14 @@
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="timeVectorConfig.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments>-j2</buildArguments>
<buildTarget>timeVectorConfig.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="install" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments>-j2</buildArguments>

View File

@ -238,7 +238,7 @@ testVSLAMConfig_LDADD = libgtsam.la
headers += $(sources:.cpp=.h)
# Timing tests
noinst_PROGRAMS = timeGaussianFactor timeGaussianFactorGraph timeRot3 timeMatrix timeSymbolMaps
noinst_PROGRAMS = timeGaussianFactor timeGaussianFactorGraph timeRot3 timeMatrix timeSymbolMaps timeVectorConfig
timeRot3_SOURCES = timeRot3.cpp
timeRot3_LDADD = libgtsam.la
timeGaussianFactor_SOURCES = timeGaussianFactor.cpp
@ -249,6 +249,8 @@ timeMatrix_SOURCES = timeMatrix.cpp
timeMatrix_LDADD = libgtsam.la
timeSymbolMaps_SOURCES = timeSymbolMaps.cpp
timeSymbolMaps_LDADD = libgtsam.la
timeVectorConfig_SOURCES = timeVectorConfig.cpp
timeVectorConfig_LDADD = libgtsam.la
# create both dynamic and static libraries
AM_CXXFLAGS = -I$(boost) -fPIC

57
cpp/timeVectorConfig.cpp Normal file
View File

@ -0,0 +1,57 @@
/*
* @file timeVectorConfig.cpp
* @brief Performs timing and profiling for VectorConfig operations
* @author Frank Dellaert
*/
#include <iostream>
#include <boost/timer.hpp>
#include "VectorConfig.h"
using namespace std;
using namespace gtsam;
/*
* Results:
* Frank's machine:
*/
double timeAssignment(size_t n, size_t m, size_t r) {
// assign a large VectorConfig
// n = number of times to loop
// m = number of vectors
// r = rows per vector
// Create 2 VectorConfigs
VectorConfig a, b;
for (int i = 0; i < m; ++i) {
Vector v = zero(r);
Symbol key('x', i);
a.add(key, v);
b.add(key, v);
}
// start timing
double elapsed;
{
boost::timer t;
for (int j = 0; j < n; ++j)
a = b;
elapsed = t.elapsed();
}
return elapsed;
}
int main(int argc, char ** argv) {
// Time assignment operator
cout << "Starting operator=() Timing" << endl;
size_t n = 1000, m = 10000, r = 3;
double time = timeAssignment(n, m, r);
cout << "Average Elapsed time for assigning " << m << "*" << r
<< " VectorConfigs: " << 10e3 * time / n << "ms." << endl;
return 0;
}