add macOS implementation

This commit is contained in:
Nick Fisher
2023-09-05 23:13:59 +08:00
parent c522cd6ee9
commit 84e3124e04
457 changed files with 169627 additions and 15 deletions

32
macos/include/TimeIt.hpp Normal file
View File

@@ -0,0 +1,32 @@
#ifndef TIMEIT_H_
#define TIMEIT_H_
#pragma once
#if __cplusplus <= 199711L
#include <ctime>
#else
#include <chrono>
#endif
class Timer
{
public:
Timer() { reset(); }
void reset();
double elapsed();
private:
#if __cplusplus <= 199711L
timespec beg_, end_;
#else
typedef std::chrono::high_resolution_clock clock_;
typedef std::chrono::duration<double, std::ratio<1> > second_;
std::chrono::time_point<clock_> beg_;
#endif
};
#endif // TIMEIT_H_