From d132066e129817ecc540d2eec306b8361da1ba20 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Mon, 28 Feb 2011 14:06:50 +0000 Subject: [PATCH] Checking in old timing script additional debug check --- gtsam/base/timing.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gtsam/base/timing.h b/gtsam/base/timing.h index 529320b50..6a7544c15 100644 --- a/gtsam/base/timing.h +++ b/gtsam/base/timing.h @@ -155,7 +155,13 @@ inline void toc_(size_t id) { std::cout << "toc(" << id << ")" << std::endl; boost::shared_ptr current(timingCurrent.lock()); if(!(id < current->parent_.lock()->children_.size() && current->parent_.lock()->children_[id] == current)) { - std::cout << "gtsam timing: Incorrect ID passed to toc" << std::endl; + if(std::find(current->parent_.lock()->children_.begin(), current->parent_.lock()->children_.end(), current) + != current->parent_.lock()->children_.end()) + std::cout << "gtsam timing: Incorrect ID passed to toc, expected " + << std::find(current->parent_.lock()->children_.begin(), current->parent_.lock()->children_.end(), current) - current->parent_.lock()->children_.begin() + << ", got " << id << std::endl; + else + std::cout << "gtsam timing: Incorrect ID passed to toc, id " << id << " does not exist" << std::endl; timingRoot->print(); throw std::invalid_argument("gtsam timing: Incorrect ID passed to toc"); } @@ -171,12 +177,13 @@ inline void toc_(size_t id) { inline void toc_(size_t id, const std::string& label) { if(ISDEBUG("timing-verbose")) std::cout << "toc(" << id << ", " << label << ")" << std::endl; -#ifdef NDEBUG + bool check = false; +#ifndef NDEBUG // If NDEBUG is defined, still do this debug check if the granular debugging // flag is enabled. If NDEBUG is not defined, always do this check. - if(ISDEBUG("timing-debug")) + check = true; #endif - { + if(check || ISDEBUG("timing-debug")) { if(label != timingCurrent.lock()->label_) { std::cerr << "gtsam timing: toc called with id=" << id << ", label=\"" << label << "\", but expecting \"" << timingCurrent.lock()->label_ << "\"" << std::endl; timingRoot->print();