Is there an equivalent instruction to rdtsc in ARM?

前端 未结 1 1816
余生分开走
余生分开走 2021-01-02 01:14

For my project I must use inline assembly instructions such as rdtsc to calculate the execution time of some C/C++ instructions.

Th

相关标签:
1条回答
  • 2021-01-02 01:22

    You should read the PMCCNTR register of a co-processor p15 (not an actual co-processor, just an entry point for CPU functions) to obtain a cycle count. Note that it is available to an unprivileged app only if:

    1. Unprivileged PMCCNTR reads are alowed:

      Bit 0 of PMUSERENR register must be set to 1 (official docs)

    2. PMCCNTR is actually counting cycles:

      Bit 31 of PMCNTENSET register must be set to 1 (official docs)

    This is a real-world example of how it`s done.

    0 讨论(0)
提交回复
热议问题