| 1 | -- Import gettime() from LuaSocket, as a way to access high-resolution time |
| 2 | -- in a platform-independent way |
| 3 | |
| 4 | local socket_gettime = require "socket".gettime; |
| 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 | |
| 13 | return { |
| 14 | now = socket_gettime; |
| 15 | monotonic = monotonic; |
| 16 | } |