libs/time.lua

changeset 471
788d4d91ef6b
parent 440
14071b3a46df
equal deleted inserted replaced
470:e690759c5072 471:788d4d91ef6b
1 -- Import gettime() from LuaSocket, as a way to access high-resolution time 1 -- Import gettime() from LuaSocket, as a way to access high-resolution time
2 -- in a platform-independent way 2 -- in a platform-independent way
3 3
4 local socket_gettime = require "socket".gettime; 4 local socket_gettime = require "socket".gettime;
5 5
6 local monotonic;
7
8 local have_system_lib, system = pcall(require, "system");
9 if have_system_lib then
10 monotonic = system.monotime;
11 end
12
6 return { 13 return {
7 now = socket_gettime; 14 now = socket_gettime;
15 monotonic = monotonic;
8 } 16 }

mercurial