+class timestamp {
+public:
+ enum class clock_type { WALLCLOCK, CPU };
+
+ timestamp(clock_type ct);
+ ~timestamp();
+ void reset();
+
+ void start();
+ void stop();
+
+ struct timespec tv_duration() const;
+ double duration() const;
+
+private:
+ clock_type clk;
+ struct timespec before;
+ struct timespec after;
+ struct timespec difference;
+
+ void get_time(struct timespec& tv);
+
+ static void tv_clear(struct timespec& a);
+ static double timertod(const struct timespec& a);
+};
+
+inline
+timestamp::timestamp(clock_type ct): clk(ct)