Skip to content
Snippets Groups Projects

Package fr3_impedance_controller_real in nix env

Merged Kevin Haninger requested to merge 7-add-local-package-to-nix-flake-new into main
1 unresolved thread
Compare and Show latest version
11 files
+ 378
169
Compare changes
  • Side-by-side
  • Inline
Files
11
+ 62
0
/*! @file Timer.hpp
* @brief Timer for measuring how long things take
*/
#ifndef TIMER_HPP_
#define TIMER_HPP_
#include <assert.h>
#include <stdint.h>
#include <time.h>
class Timer
{
private:
struct timespec start_time_;
public:
/*!
* Construct and start timer
*/
explicit Timer()
{
start();
};
/*!
* Start the timer
*/
void start()
{
clock_gettime(CLOCK_MONOTONIC, &start_time_);
}
/*!
* Get milliseconds elapsed
*/
double getMillisec()
{
return (double)getNanosec() / 1.e6;
}
/*!
*Get nanoseconds elapsed
*/
int64_t getNanosec()
{
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return (int64_t)(now.tv_nsec - start_time_.tv_nsec) +
1'000'000'000 * (now.tv_sec - start_time_.tv_sec);
}
/*!
* Get seconds elapsed
*/
double getSeconds()
{
return (double)getNanosec() / 1.e9;
}
};
#endif // TIMER_HPP_
\ No newline at end of file
Loading