Skip to content

Instantly share code, notes, and snippets.

@qi7chen
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save qi7chen/3d11f2cc50421af30ca9 to your computer and use it in GitHub Desktop.

Select an option

Save qi7chen/3d11f2cc50421af30ca9 to your computer and use it in GitHub Desktop.
#pragma once
#include <time.h>
#include <stdint.h>
#include <array>
typedef std::array<uint8_t, 16> UUID_T;
#ifdef _MSC_VER
#pragma optimize("", off)
template <class T>
void doNotOptimizeAway(T&& datum) {
datum = datum;
}
#pragma optimize("", on)
#else
template <class T>
void doNotOptimizeAway(T&& datum) {
asm volatile("" : "+r" (datum));
}
#endif
class TimeCounter
{
public:
TimeCounter();
~TimeCounter();
private:
#ifdef _WIN32
uint32_t start_;
#else
timespec start_;
#endif
};
UUID_T createUUID();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment