/* ---------------------------------------------------------------------------- * 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 timeMatrix.cpp * @brief Performs timing and profiling for Matrix operations * @author Alex Cunningham */ #include #include #include using namespace std; using namespace gtsam; /* * Results: * Alex's Machine: * (using p = 100000 m = 10 n = 12 reps = 50) - Average times * - (1st pass of simple changes) no pass: 0.184 sec , pass: 0.181 sec * - (1st rev memcpy) no pass: 0.181 sec , pass: 0.180 sec * - (1st rev matrix_range) no pass: 0.186 sec , pass: 0.184 sec * (using p = 10 m = 10 n = 12 reps = 10000000) * - (matrix_range version) no pass: 24.21 sec , pass: 23.97 sec * - (memcpy version) no pass: 18.96 sec , pass: 18.39 sec * - (original version) no pass: 23.45 sec , pass: 22.80 sec * - rev 2100 no pass: 18.45 sec , pass: 18.35 sec */ double timeCollect(size_t p, size_t m, size_t n, bool passDims, size_t reps) { // create a large number of matrices // p = number of matrices // m = rows per matrix // n = columns per matrix // reps = number of repetitions // fill the matrices with identities vector matrices; for (size_t i=0; i(M, j); result = column(M, j); elapsed = t.elapsed(); } return elapsed; } /* * Results * Alex's machine * * Runs at reps = 500000 * Baseline (no householder, just matrix copy) : 0.05 sec * Initial : 8.20 sec * All in one function : 7.89 sec * Replace householder update with GSL, ATLAS : 0.92 sec * * Runs at reps = 2000000 * Baseline (GSL/ATLAS householder update) : 3.61 sec * * Runs at reps = 5000000 * Baseline : 8.76 sec * GSL/Atlas version of updateAb : 9.03 sec // Why does this have an effect? * Inlining house() : 6.33 sec * Inlining householder_update [GSL] : 6.15 sec * Rev 2100 : 5.75 sec * */ double timeHouseholder(size_t reps) { // create a matrix Matrix Abase = (Matrix(4, 7) << -5, 0, 5, 0, 0, 0, -1, 00, -5, 0, 5, 0, 0, 1.5, 10, 0, 0, 0,-10, 0, 2, 00, 10, 0, 0, 0,-10, -1).finished(); // perform timing double elapsed; { boost::timer t; for (size_t i=0; i