Skip to content
Snippets Groups Projects
Commit 6ffd1b8d authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Log time of each iteration.

parent ee435647
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,40 @@ using namespace std;
using namespace dynamicgraph::sot;
namespace po = boost::program_options;
struct DataToLog
{
const std::size_t N;
std::size_t idx;
std::vector<double> times;
DataToLog (std::size_t N_)
: N (N_)
, idx (0)
, times (N, 0)
{}
void record (const double t)
{
times[idx] = t;
++idx;
if (idx == N) idx = 0;
}
void save (const char* prefix)
{
std::ostringstream oss;
oss << prefix << "-times.log";
std::ofstream aof(oss.str().c_str());
if (aof.is_open()) {
for (std::size_t k = 0; k < N; ++k) {
aof << times[ (idx + k) % N ] << '\n';
}
}
aof.close();
}
};
void workThreadLoader(SotLoader *aSotLoader)
......@@ -59,10 +93,12 @@ void workThreadLoader(SotLoader *aSotLoader)
gettimeofday(&stop,0);
unsigned long long dt = 1000000 * (stop.tv_sec - start.tv_sec) + (stop.tv_usec - start.tv_usec);
dataToLog.record ((double)dt * 1e-6);
if (period > dt) {
usleep(period - (unsigned)dt);
}
}
dataToLog.save ("/tmp/geometric_simu");
cond.notify_all();
ros::waitForShutdown();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment