mirror of
https://github.com/google/benchmark.git
synced 2025-03-27 12:30:25 +08:00
Merge pull request #176 from enh/cycle-timer-aarch64
Add aarch64 support to src/cycleclock.h.
This commit is contained in:
commit
af489cd4a3
@ -99,6 +99,14 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() {
|
|||||||
_asm rdtsc
|
_asm rdtsc
|
||||||
#elif defined(COMPILER_MSVC)
|
#elif defined(COMPILER_MSVC)
|
||||||
return __rdtsc();
|
return __rdtsc();
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
// System timer of ARMv8 runs at a different frequency than the CPU's.
|
||||||
|
// The frequency is fixed, typically in the range 1-50MHz. It can be
|
||||||
|
// read at CNTFRQ special register. We assume the OS has set up
|
||||||
|
// the virtual timer properly.
|
||||||
|
int64_t virtual_timer_value;
|
||||||
|
asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
|
||||||
|
return virtual_timer_value;
|
||||||
#elif defined(__ARM_ARCH)
|
#elif defined(__ARM_ARCH)
|
||||||
#if (__ARM_ARCH >= 6) // V6 is the earliest arch that has a standard cyclecount
|
#if (__ARM_ARCH >= 6) // V6 is the earliest arch that has a standard cyclecount
|
||||||
uint32_t pmccntr;
|
uint32_t pmccntr;
|
||||||
|
Loading…
Reference in New Issue
Block a user