snort supports the use of rdtsc to get fast, accurate-enough timing on
x86 platforms. The CNTVCT_EL0 register on ARM64 provides a usable
equivalent to userspace code on that platform. It's not the actual
processor clock rate but can vary in accuracy from 1-50Mhz. Its use
gives a ~10% performance improvement on an A53 based platform.
static uint64_t counter()
{
+#if defined(__aarch64__)
+ uint64_t ticks;
+
+ asm volatile("mrs %0, CNTVCT_EL0" : "=r" (ticks));
+ return ticks;
+#else
+ // Default to x86, other archs will compile error anyway
uint32_t lo, hi;
asm volatile("rdtsc" : "=a" (lo), "=d" (hi));
return ((uint64_t)hi << 32) | lo;
+#endif
}
static time_point now() noexcept