Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I use __rdtsc() compiler intrinsic

What do you do on ARM?



Read `cntvct_el0` with the `mrs` instruction. [1]

[1]: https://developer.arm.com/documentation/102379/0104/The-proc...



See manual page and changelog.

* https://jdebp.uk/Softwares/djbwares/guide/commands/clockspee...

* https://github.com/jdebp/djbwares/commit/8d2c20930c8700b1786...

Yes, 27 years later it now compiles on a non-Intel architecture. (-:


Just use gettimeofday/clock_gettime via vDSO.

  struct timespec ts;
  clock_gettime(CLOCK_MONOTONIC, &ts);
On arm64 it directly uses the cntvct_el0 register under the hood but with a standard/easy to use API instead of messing about with inline assembly. Also avoids a context switch because it's vDSO.


Use a Raspberry Pi or something.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: