timeLinearize.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #pragma once
20 
23 
24 #include <time.h>
25 #include <iostream>
26 #include <iomanip>
27 
28 static const int n = 1000000;
29 
30 void timeSingleThreaded(const std::string& str,
32  long timeLog = clock();
34  for (int i = 0; i < n; i++)
35  gf = f->linearize(values);
36  long timeLog2 = clock();
37  double seconds = (double) (timeLog2 - timeLog) / CLOCKS_PER_SEC;
38  std::cout << std::setprecision(3);
39  std::cout << str << ((double) seconds * 1000000 / n) << " musecs/call"
40  << std::endl;
41 }
42 
43 void timeMultiThreaded(const std::string& str,
46  for (int i = 0; i < n; i++)
47  graph.push_back(f);
48  long timeLog = clock();
50  long timeLog2 = clock();
51  double seconds = (double) (timeLog2 - timeLog) / CLOCKS_PER_SEC;
52  std::cout << std::setprecision(3);
53  std::cout << str << ((double) seconds * 1000000 / n) << " musecs/call"
54  << std::endl;
55 }
56 
gtsam::NonlinearFactor::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: NonlinearFactor.h:78
GaussianFactorGraph.h
Linear Factor Graph where all factors are Gaussians.
gtsam::GaussianFactorGraph::shared_ptr
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianFactorGraph.h:82
n
static const int n
Definition: timeLinearize.h:28
timeSingleThreaded
void timeSingleThreaded(const std::string &str, const gtsam::NonlinearFactor::shared_ptr &f, const gtsam::Values &values)
Definition: timeLinearize.h:30
gtsam::NonlinearFactorGraph
Definition: NonlinearFactorGraph.h:55
gtsam::GaussianFactor::shared_ptr
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianFactor.h:42
str
Definition: pytypes.h:1524
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
timeMultiThreaded
void timeMultiThreaded(const std::string &str, const gtsam::NonlinearFactor::shared_ptr &f, const gtsam::Values &values)
Definition: timeLinearize.h:43
NonlinearFactorGraph.h
Factor Graph consisting of non-linear factors.
leaf::values
leaf::MyValues values
gtsam::Values
Definition: Values.h:65
graph
NonlinearFactorGraph graph
Definition: doc/Code/OdometryExample.cpp:2
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9


gtsam
Author(s):
autogenerated on Thu Jun 13 2024 03:10:49