Alex Rivera | Logout

Lua - Current time in milliseconds

Asked 2009-01-20T21:03:34.187
92

Is there a common way to get the current time in or with milliseconds?

There is os.time(), but it only provides full seconds.

Edit
Report

3 Answers

65

I use LuaSocket to get more precision.

require "socket"
print("Milliseconds: " .. socket.gettime()*1000)

This adds a dependency of course, but works fine for personal use (in benchmarking scripts for example).

answered 2009-01-22T20:07:18.633
2

Kevlar is correct.

An alternative to a custom DLL is Lua Alien

answered 2009-01-20T21:15:30.683
0

You can use C function gettimeofday : http://www.opengroup.org/onlinepubs/000095399/functions/gettimeofday.html

Here C library 'ul_time', function sec_usec resides in 'time' global table and returns seconds, useconds. Copy DLL to Lua folder, open it with require 'ul_time'.

http://depositfiles.com/files/3g2fx7dij

answered 2009-03-15T14:01:34.100

Your Answer