
import win;

::LARGE_INTEGER := class{ 
    long QuadPart;
}

::QueryPerformanceCounter := ::Kernel32.api("QueryPerformanceCounter","int(struct &lpPerformanceCount)")
::QueryPerformanceFrequency := ::Kernel32.api("QueryPerformanceFrequency","int(struct &lpPerformanceCount)")


var freq = LARGE_INTEGER();
var startf = LARGE_INTEGER();
var endf = LARGE_INTEGER();

var ret;

ret,freq = ::QueryPerformanceFrequency(freq);

startQuadPart = 10;
us = 100000;
count = (us * freq.QuadPart) / (1000 * 1000);

QueryPerformanceCounter(startf);
count += startQuadPart ;


do
{
   ret,endf = QueryPerformanceCounter(endf);
}while(endf.QuadPart < count);

io.open()
io.print( string.format('us %u, elaps %u ms\r\n', us, endf.QuadPart-startf.QuadPart) );
