Commit e8514ecb authored by Olivier Stasse's avatar Olivier Stasse
Browse files

Fix warnings - Make explicit strong cast, and reorder constructor initialization.

parent 44979b79
......@@ -41,8 +41,8 @@ public:
private:
double m_dt; /// sampling timestep of the input signal
int m_x_size;
int m_filter_order_m;
int m_filter_order_n;
Eigen::Index m_filter_order_m;
Eigen::Index m_filter_order_n;
Eigen::VectorXd m_filter_numerator;
Eigen::VectorXd m_filter_denominator;
......
......@@ -44,11 +44,11 @@ CausalFilter::CausalFilter(const double &timestep,
, m_filter_order_n(filter_denominator.size())
, m_filter_numerator(filter_numerator)
, m_filter_denominator(filter_denominator)
, first_sample(true)
, pt_numerator(0)
, pt_denominator(0)
, input_buffer(Eigen::MatrixXd::Zero(xSize, filter_numerator.size()))
, output_buffer(Eigen::MatrixXd::Zero(xSize, filter_denominator.size()-1))
, first_sample(true)
, output_buffer(Eigen::MatrixXd::Zero(xSize,filter_denominator.size()-1))
{
assert(timestep>0.0 && "Timestep should be > 0");
assert(m_filter_numerator.size() == m_filter_order_m);
......@@ -83,7 +83,7 @@ void CausalFilter::get_x_dx_ddx(const Eigen::VectorXd& base_x,
x_output_dx_ddx.head(m_x_size) = (input_buffer*b-output_buffer*a)/m_filter_denominator[0];
//Finite Difference
int pt_denominator_prev = (pt_denominator == 0) ? m_filter_order_n-2 : pt_denominator-1;
Eigen::Index pt_denominator_prev = (pt_denominator == 0) ? m_filter_order_n-2 : pt_denominator-1;
x_output_dx_ddx.segment(m_x_size,m_x_size) = (x_output_dx_ddx.head(m_x_size)-output_buffer.col(pt_denominator))/m_dt;
x_output_dx_ddx.tail(m_x_size) = (x_output_dx_ddx.head(m_x_size)-2*output_buffer.col(pt_denominator)+output_buffer.col(pt_denominator_prev))/m_dt/m_dt;
......@@ -98,8 +98,8 @@ void CausalFilter::get_x_dx_ddx(const Eigen::VectorXd& base_x,
void CausalFilter::switch_filter(const Eigen::VectorXd& filter_numerator,
const Eigen::VectorXd& filter_denominator)
{
int filter_order_m = filter_numerator.size();
int filter_order_n = filter_denominator.size();
Eigen::Index filter_order_m = filter_numerator.size();
Eigen::Index filter_order_n = filter_denominator.size();
Eigen::VectorXd current_x(input_buffer.col(pt_numerator));
......
......@@ -54,16 +54,16 @@ DeviceTorqueCtrl::DeviceTorqueCtrl(std::string RobotName):
currentSOUT_ ("DeviceTorqueCtrl(" + RobotName + ")::output(vector)::currents"),
p_gainsSOUT_ ("DeviceTorqueCtrl(" + RobotName + ")::output(vector)::p_gains"),
d_gainsSOUT_ ("DeviceTorqueCtrl(" + RobotName + ")::output(vector)::d_gains"),
CONSTRUCT_SIGNAL_IN(kp_constraints, dynamicgraph::Vector),
CONSTRUCT_SIGNAL_IN(kd_constraints, dynamicgraph::Vector),
CONSTRUCT_SIGNAL_IN(rotor_inertias, dynamicgraph::Vector),
CONSTRUCT_SIGNAL_IN(gear_ratios, dynamicgraph::Vector),
accelerometer_ (3),
gyrometer_ (3),
m_isTorqueControlled(true),
m_numericalDamping(1e-8),
normalDistribution_(0.0, FORCE_SENSOR_NOISE_STD_DEV),
normalRandomNumberGenerator_(randomNumberGenerator_,normalDistribution_),
m_isTorqueControlled(true),
CONSTRUCT_SIGNAL_IN(kp_constraints, dynamicgraph::Vector),
CONSTRUCT_SIGNAL_IN(kd_constraints, dynamicgraph::Vector),
CONSTRUCT_SIGNAL_IN(rotor_inertias, dynamicgraph::Vector),
CONSTRUCT_SIGNAL_IN(gear_ratios, dynamicgraph::Vector)
normalRandomNumberGenerator_(randomNumberGenerator_,normalDistribution_)
{
forcesSIN_[0] = new SignalPtr<dynamicgraph::Vector, int>(NULL, "DeviceTorqueCtrl::input(vector6)::inputForceRLEG");
forcesSIN_[1] = new SignalPtr<dynamicgraph::Vector, int>(NULL, "DeviceTorqueCtrl::input(vector6)::inputForceLLEG");
......@@ -133,7 +133,7 @@ void DeviceTorqueCtrl::init(const double& dt, const std::string& robotRef)
return;
}
m_nj = m_robot_util->m_nbJoints;
m_nj = static_cast<int>(m_robot_util->m_nbJoints);
const dynamicgraph::sot::Vector6d& kp_contact = m_kp_constraintsSIN(0);
const dynamicgraph::sot::Vector6d& kd_contact = m_kd_constraintsSIN(0);
......@@ -188,7 +188,7 @@ void DeviceTorqueCtrl::init(const double& dt, const std::string& robotRef)
void DeviceTorqueCtrl::setStateSize(const unsigned int& size)
{
assert(size==m_nj+6);
assert(size==static_cast<unsigned int>(m_nj+6));
Device::setStateSize(size);
base6d_encoders_.resize(size);
......@@ -281,7 +281,7 @@ void DeviceTorqueCtrl::computeForwardDynamics()
m_dvBar, m_numericalDamping);
// compute base of null space of constraint Jacobian
int r = (m_Jc_svd.singularValues().array()>1e-8).count();
Eigen::Index r = (m_Jc_svd.singularValues().array()>1e-8).count();
m_Z = m_Jc_svd.matrixV().rightCols(m_nj+6-r);
// compute constrained accelerations ddq_c = (Z^T*M*Z)^{-1}*Z^T*(S^T*tau - h - M*ddqBar)
......
......@@ -60,10 +60,10 @@ namespace dynamicgraph
,CONSTRUCT_SIGNAL_OUT(accelerometer_out, dynamicgraph::Vector, m_accelerometer_inSIN)
,CONSTRUCT_SIGNAL_OUT(gyrometer_out, dynamicgraph::Vector, m_gyrometer_inSIN)
,m_initSucceeded(false)
,m_dt(static_cast<float>(0.001))
,m_update_cycles_left(0)
,m_update_cycles(0)
,m_dt(0.001)
,m_a_gyro_DC_blocker(1.0)
,m_a_gyro_DC_blocker(static_cast<float>(1.0))
{
Entity::signalRegistration( INPUT_SIGNALS << OUTPUT_SIGNALS );
......@@ -98,7 +98,7 @@ namespace dynamicgraph
{
if(dt<=0.0)
return SEND_MSG("Timestep must be positive", MSG_TYPE_ERROR);
m_dt = dt;
m_dt = static_cast<float>(dt);
m_initSucceeded = true;
// try to read IMU calibration data from file
......
......@@ -53,12 +53,12 @@ namespace dynamicgraph
,CONSTRUCT_SIGNAL(x, OUT, dynamicgraph::Vector)
,CONSTRUCT_SIGNAL_OUT(dx, dynamicgraph::Vector, m_xSOUT)
,CONSTRUCT_SIGNAL_OUT(ddx, dynamicgraph::Vector, m_xSOUT)
,m_firstIter(true)
,m_splineReady(false)
,m_initSucceeded(false)
,m_n(1)
,m_firstIter(true)
,m_t(0)
,m_n(1)
,m_iterLast(0)
,m_splineReady(false)
{
BIND_SIGNAL_TO_FUNCTION(x, OUT, dynamicgraph::Vector);
......@@ -148,7 +148,7 @@ namespace dynamicgraph
m_linChirpTrajGen.resize(m_n);
m_currentTrajGen.resize(m_n);
m_noTrajGen.resize(m_n);
for(int i=0; i<m_n; i++)
for(unsigned int i=0; i<m_n; i++)
{
m_minJerkTrajGen[i] = new parametriccurves::MinimumJerk<double,1>(5.0);
m_sinTrajGen[i] = new parametriccurves::InfiniteSinusoid<double,1>(5.0);
......@@ -199,7 +199,7 @@ namespace dynamicgraph
m_currentTrajGen[i]->setInitialPoint(initial_value(i));
m_firstIter = false;
}
else if(iter == m_iterLast)
else if(iter == static_cast<int>(m_iterLast))
{
if (m_triggerSIN(iter)==true && m_splineReady) startSpline();
if(m_status[0]==JTG_TEXT_FILE)
......@@ -279,12 +279,12 @@ namespace dynamicgraph
{
if(!m_initSucceeded)
{
SEND_WARNING_STREAM_MSG("Cannot compute signal positionDes before initialization!");
std::ostringstream oss("Cannot compute signal positionDes before initialization! iter:");
oss << iter;
SEND_WARNING_STREAM_MSG(oss.str());
return s;
}
const dynamicgraph::Vector& x = m_xSOUT(iter);
if(s.size()!=m_n)
s.resize(m_n);
if(m_status[0]==JTG_TEXT_FILE)
......@@ -304,12 +304,12 @@ namespace dynamicgraph
{
if(!m_initSucceeded)
{
SEND_WARNING_STREAM_MSG("Cannot compute signal positionDes before initialization!");
std::ostringstream oss("Cannot compute signal positionDes before initialization! iter:");
oss << iter;
SEND_WARNING_STREAM_MSG(oss.str());
return s;
}
const dynamicgraph::Vector& x = m_xSOUT(iter);
if(s.size()!=m_n)
s.resize(m_n);
......@@ -332,7 +332,7 @@ namespace dynamicgraph
void NdTrajectoryGenerator::getValue(const int& id)
{
if(id<0 || id>=m_n)
if(id<0 || id>=static_cast<int>(m_n))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
SEND_MSG("Current value of component "+toString(id)+" is "+toString( (*m_currentTrajGen[id])(m_t)[0]) , MSG_TYPE_INFO);
......@@ -450,7 +450,7 @@ namespace dynamicgraph
if(!m_initSucceeded)
return SEND_MSG("Cannot start sinusoid before initialization!",MSG_TYPE_ERROR);
if(id<0 || id>=m_n)
if(id<0 || id>=static_cast<int>(m_n))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
unsigned int i = id;
if(time<=0.0)
......@@ -500,15 +500,13 @@ namespace dynamicgraph
{
if(!m_initSucceeded)
return SEND_MSG("Cannot start constant-acceleration trajectory before initialization!",MSG_TYPE_ERROR);
if(id<0 || id>=m_n)
if(id<0 || id>=static_cast<int>(m_n))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
unsigned int i = id;
if(time<=0.0)
return SEND_MSG("Trajectory time must be a positive number", MSG_TYPE_ERROR);
if(m_status[i]!=JTG_STOP)
return SEND_MSG("You cannot move the specified component because it is already controlled.", MSG_TYPE_ERROR);
// if(!isJointInRange(i, xFinal))
// return;
m_constAccTrajGen[i]->setInitialPoint((*m_noTrajGen[i])(m_t)[0]);
SEND_MSG("Set initial point of const-acc trajectory to "+toString((*m_noTrajGen[i])(m_t)[0]),MSG_TYPE_DEBUG);
......@@ -522,15 +520,13 @@ namespace dynamicgraph
{
if(!m_initSucceeded)
return SEND_MSG("Cannot start linear chirp before initialization!",MSG_TYPE_ERROR);
if(id<0 || id>=m_n)
if(id<0 || id>=static_cast<int>(m_n))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
unsigned int i = id;
if(time<=0.0)
return SEND_MSG("Trajectory time must be a positive number", MSG_TYPE_ERROR);
if(m_status[i]!=JTG_STOP)
return SEND_MSG("You cannot move the specified component because it is already controlled.", MSG_TYPE_ERROR);
// if(!isJointInRange(i, xFinal))
// return;
if(f0>f1)
return SEND_MSG("f0 "+toString(f0)+" cannot to be more than f1 "+toString(f1),MSG_TYPE_ERROR);
if(f0<=0.0)
......@@ -556,7 +552,7 @@ namespace dynamicgraph
if(!m_initSucceeded)
return SEND_MSG("Cannot move value before initialization!",MSG_TYPE_ERROR);
unsigned int i = id;
if(id<0 || id>=m_n)
if(id<0 || id>=static_cast<int>(m_n))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
if(time<=0.0)
return SEND_MSG("Trajectory time must be a positive number", MSG_TYPE_ERROR);
......@@ -591,7 +587,7 @@ namespace dynamicgraph
m_t = 0.0;
return;
}
if(id<0 || id>=m_n)
if(id<0 || id>=static_cast<int>(m_n))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
unsigned int i = id;
m_noTrajGen[i]->setInitialPoint((*m_currentTrajGen[i])(m_t)[0]);
......
......@@ -258,7 +258,7 @@ void QuadEstimator::estimate(std::vector<double>& esteem,
{
c0_[i] = 0.0; c1_[i] = 0.0; c2_[i] = 0.0;
// Retrieve the data in the window
for (int j = 0; j < N_; ++j)
for (unsigned int j = 0; j < N_; ++j)
{
idx = (pt_+j);
if (idx >= N_ ) idx -= N_;
......
......@@ -50,17 +50,17 @@ namespace dynamicgraph
SE3TrajectoryGenerator(const std::string& name)
: Entity(name)
,CONSTRUCT_SIGNAL_IN(initial_value,dynamicgraph::Vector)
,CONSTRUCT_SIGNAL_IN(trigger,bool)
,CONSTRUCT_SIGNAL(x, OUT, dynamicgraph::Vector)
,CONSTRUCT_SIGNAL_IN(trigger,bool)
,CONSTRUCT_SIGNAL_OUT(dx, dynamicgraph::Vector, m_xSOUT)
,CONSTRUCT_SIGNAL_OUT(ddx, dynamicgraph::Vector, m_xSOUT)
,m_firstIter(true)
,m_initSucceeded(false)
,m_splineReady(false)
,m_t(0)
,m_firstIter(true)
,m_np(12)
,m_nv(6)
,m_iterLast(0)
,m_t(0)
,m_splineReady(false)
{
BIND_SIGNAL_TO_FUNCTION(x, OUT, dynamicgraph::Vector);
......@@ -146,7 +146,7 @@ namespace dynamicgraph
m_linChirpTrajGen.resize(m_np);
m_currentTrajGen.resize(m_np);
m_noTrajGen.resize(m_np);
for(int i=0; i<m_np; i++)
for(unsigned int i=0; i<m_np; i++)
{
m_minJerkTrajGen[i] = new MinimumJerkTrajectoryGenerator(dt,5.0,1);
m_sinTrajGen[i] = new SinusoidTrajectoryGenerator(dt,5.0,1);
......@@ -193,7 +193,7 @@ namespace dynamicgraph
m_currentTrajGen[i]->set_initial_point(initial_value(i));
m_firstIter = false;
}
else if(iter == m_iterLast)
else if(iter == static_cast<int>(m_iterLast))
{
if (m_triggerSIN(iter)==true && m_splineReady) startSpline();
if(m_status[0]==TG_TEXT_FILE)
......@@ -285,11 +285,12 @@ namespace dynamicgraph
{
if(!m_initSucceeded)
{
SEND_WARNING_STREAM_MSG("Cannot compute signal positionDes before initialization!");
std::ostringstream oss("Cannot compute signal positionDes before initialization! iter:");
oss << iter;
SEND_WARNING_STREAM_MSG(oss.str());
return s;
}
const dynamicgraph::Vector& x = m_xSOUT(iter);
if(s.size()!=m_nv)
s.resize(m_nv);
......@@ -315,11 +316,12 @@ namespace dynamicgraph
{
if(!m_initSucceeded)
{
SEND_WARNING_STREAM_MSG("Cannot compute signal positionDes before initialization!");
std::ostringstream oss("Cannot compute signal positionDes before initialization! iter:");
oss << iter;
SEND_WARNING_STREAM_MSG(oss.str());
return s;
}
const dynamicgraph::Vector& x = m_xSOUT(iter);
if(s.size()!=m_nv)
s.resize(m_nv);
......@@ -348,7 +350,7 @@ namespace dynamicgraph
void SE3TrajectoryGenerator::getValue(const int& id)
{
if(id<0 || id>=m_np)
if(id<0 || id>=static_cast<int>(m_np))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
SEND_MSG("Current value of component "+toString(id)+" is "+toString( m_currentTrajGen[id]->getPos()(0) ), MSG_TYPE_INFO);
......@@ -466,7 +468,7 @@ namespace dynamicgraph
if(!m_initSucceeded)
return SEND_MSG("Cannot start sinusoid before initialization!",MSG_TYPE_ERROR);
if(id<0 || id>=m_np)
if(id<0 || id>=static_cast<int>(m_np))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
unsigned int i = id;
if(time<=0.0)
......@@ -486,7 +488,7 @@ namespace dynamicgraph
{
if(!m_initSucceeded)
return SEND_MSG("Cannot start triangle before initialization!",MSG_TYPE_ERROR);
if(id<0 || id>=m_np)
if(id<0 || id>=static_cast<int>(m_np))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
unsigned int i = id;
if(m_status[i]!=TG_STOP)
......@@ -510,7 +512,7 @@ namespace dynamicgraph
{
if(!m_initSucceeded)
return SEND_MSG("Cannot start constant-acceleration trajectory before initialization!",MSG_TYPE_ERROR);
if(id<0 || id>=m_np)
if(id<0 || id>=static_cast<int>(m_np))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
unsigned int i = id;
if(time<=0.0)
......@@ -530,7 +532,7 @@ namespace dynamicgraph
{
if(!m_initSucceeded)
return SEND_MSG("Cannot start linear chirp before initialization!",MSG_TYPE_ERROR);
if(id<0 || id>=m_np)
if(id<0 || id>=static_cast<int>(m_np))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
unsigned int i = id;
if(time<=0.0)
......@@ -561,7 +563,7 @@ namespace dynamicgraph
if(!m_initSucceeded)
return SEND_MSG("Cannot move value before initialization!",MSG_TYPE_ERROR);
unsigned int i = id;
if(id<0 || id>=m_np)
if(id<0 || id>=static_cast<int>(m_np))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
if(time<=0.0)
return SEND_MSG("Trajectory time must be a positive number", MSG_TYPE_ERROR);
......@@ -581,7 +583,6 @@ namespace dynamicgraph
if(!m_initSucceeded)
return SEND_MSG("Cannot stop value before initialization!",MSG_TYPE_ERROR);
const dynamicgraph::Vector& initial_value = m_initial_valueSIN.accessCopy();
if(id==-1) //Stop entire vector
{
for(unsigned int i=0; i<m_np; i++)
......@@ -593,7 +594,7 @@ namespace dynamicgraph
}
return;
}
if(id<0 || id>=m_np)
if(id<0 || id>=static_cast<int>(m_np))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
unsigned int i = id;
m_noTrajGen[i]->set_initial_point(m_currentTrajGen[i]->getPos());
......
/*
Copyright (c) 2010-2013 Tommaso Urli
Tommaso Urli tommaso.urli@uniud.it University of Udine
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef WIN32
#include <sys/time.h>
#else
#include <Windows.h>
#include <iomanip>
#endif
#include <iomanip> // std::setprecision
#include "sot/torque_control/utils/Stdafx.hh"
#include "sot/torque_control/utils/stop-watch.hh"
using std::map;
using std::string;
using std::ostringstream;
//#define START_PROFILER(name) getProfiler().start(name)
//#define STOP_PROFILER(name) getProfiler().stop(name)
Stopwatch& getProfiler()
{
static Stopwatch s(REAL_TIME); // alternatives are CPU_TIME and REAL_TIME
return s;
}
Stopwatch::Stopwatch(StopwatchMode _mode)
: active(true), mode(_mode)
{
records_of = new map<string, PerformanceData>();
}
Stopwatch::~Stopwatch()
{
delete records_of;
}
void Stopwatch::set_mode(StopwatchMode new_mode)
{
mode = new_mode;
}
bool Stopwatch::performance_exists(string perf_name)
{
return (records_of->find(perf_name) != records_of->end());
}
long double Stopwatch::take_time()
{
if ( mode == CPU_TIME ) {
// Use ctime
return clock();
} else if ( mode == REAL_TIME ) {
// Query operating system
#ifdef WIN32
/* In case of usage under Windows */
FILETIME ft;
LARGE_INTEGER intervals;
// Get the amount of 100 nanoseconds intervals elapsed since January 1, 1601
// (UTC)
GetSystemTimeAsFileTime(&ft);
intervals.LowPart = ft.dwLowDateTime;
intervals.HighPart = ft.dwHighDateTime;
long double measure = intervals.QuadPart;
measure -= 116444736000000000.0; // Convert to UNIX epoch time
measure /= 10000000.0; // Convert to seconds
return measure;
#else
/* Linux, MacOS, ... */
struct timeval tv;
gettimeofday(&tv, NULL);
long double measure = tv.tv_usec;
measure /= 1000000.0; // Convert to seconds
measure += tv.tv_sec; // Add seconds part
return measure;
#endif
} else {
// If mode == NONE, clock has not been initialized, then throw exception
throw StopwatchException("Clock not initialized to a time taking mode!");
}
}
void Stopwatch::start(string perf_name)
{
if (!active) return;
// Just works if not already present
records_of->insert(make_pair(perf_name, PerformanceData()));
PerformanceData& perf_info = records_of->find(perf_name)->second;
// Take ctime
perf_info.clock_start = take_time();
// If this is a new start (i.e. not a restart)
// if (!perf_info.paused)
// perf_info.last_time = 0;
perf_info.paused = false;
}
void Stopwatch::stop(string perf_name)
{
if (!active) return;
long double clock_end = take_time();
// Try to recover performance data
if ( !performance_exists(perf_name) )
throw StopwatchException("Performance not initialized.");
PerformanceData& perf_info = records_of->find(perf_name)->second;
// check whether the performance has been reset
if(perf_info.clock_start==0)
return;
perf_info.stops++;
long double lapse = clock_end - perf_info.clock_start;
if ( mode == CPU_TIME )
lapse /= (double) CLOCKS_PER_SEC;
// Update last time
perf_info.last_time = lapse;
// Update min/max time
if ( lapse >= perf_info.max_time ) perf_info.max_time = lapse;
if ( lapse <= perf_info.min_time || perf_info.min_time == 0 )
perf_info.min_time = lapse;
// Update total time
perf_info.total_time += lapse;
}
void Stopwatch::pause(string perf_name)
{
if (!active) return;
long double clock_end = clock();
// Try to recover performance data
if ( !performance_exists(perf_name) )
throw StopwatchException("Performance not initialized.");
PerformanceData& perf_info = records_of->find(perf_name)->second;
// check whether the performance has been reset
if(perf_info.clock_start==0)
return;
long double lapse = clock_end - perf_info.clock_start;
// Update total time
perf_info.last_time += lapse;
perf_info.total_time += lapse;
}
void Stopwatch::reset_all()
{
if (!active) return;
map<string, PerformanceData>::iterator it;
for (it = records_of->begin(); it != records_of->end(); ++it) {
reset(it->first);
}
}
void Stopwatch::report_all(int precision, std::ostream& output)
{
if (!active) return;