[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Time measurement
- From: matias.guijarro@...
- Date: Tue, 23 Sep 2008 14:25:42 +0200
Hello,
Quoting Shmuel Zeigerman <shmuz@013net.net>:
[...]
> The questions:
>
> 1. How can I get time intervals of waiting for keyboard input measured
> with the 100 ms accuracy under Linux?
>
I think you should write your own Lua C function,
calling "gettimeofday" (see Linux man page) ; something
like :
int lua_gettime(lua_State *L)
{
struct timeval tv;
struct timezone tz;
if (gettimeofday(&tv, &tz) == 0) {
lua_pushnumber(L, tv.tv_sec + tv.tv_usec*0.000001);
return 1;
} else {
luaL_error(L, "could not get time (gettimeofday failed)");
return 0;
}
}
Then you do like with os.clock, but you call your function instead
> 2. Is there a Lua solution to this problem that is portable between (at
> least) Linux and Windows?
AFAIK, I am afraid there is no portable solution.
Cheers,
Matias.