Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tea/util/measure_c.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <inttypes.h>
#include <time.h>

#ifdef __APPLE__
#include "mach/mach_time.h"
Expand All @@ -17,11 +18,15 @@ inline int64_t MeasureTicks() {
uint64_t low, high;
__asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
return ((high << 32) | low);
#elif defined(__aarch64__)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (int64_t)ts.tv_sec * 1000000000LL + (int64_t)ts.tv_nsec;
#else
static_assert(false);
static_assert(false, "MeasureTicks not implemented for this architecture");
#endif
}

#ifdef __cplusplus
}
#endif
#endif
Loading