Re: RDTSC

  • From: Mike Pall <mike-1209@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 10 Sep 2012 18:24:27 +0200

Luke Gorrie wrote:
> I'd like to execute the x86 RDTSC instruction and load the result into
> a Lua variable. Is there a clever JIT'ey way to do this or should I do
> it in C?

There's no support for inline assembler (yet). Wrap it with a
C function and call that via the FFI.

BTW: RDTSC has its pitfalls, especially on very short or very long
code sequences. Unfilled pipelines, caches, task switches, power
saving features, unsynchronized cores -- lots of things can
disturb its output. Be very careful when interpreting the results.

--Mike

  • References:

Other related posts: