源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

lua中使用毫秒精度时间的方法

  • 时间:2020-05-18 21:06 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:lua中使用毫秒精度时间的方法
lua自带的时间函数只能到秒的精度。 为了统计到毫秒精度的时间,可以使用luasocket。下载地址[url=http://files.luaforge.net/releases/luasocket/luasocket]http://files.luaforge.net/releases/luasocket/luasocket[/url] 编译安装的时候,你可能需要在源码包根目录下的config文件中指定LUAINC变量为你的lua路径。
[u]复制代码[/u] 代码如下:
local socket = require "socket" local t0 = socket.gettime() -- do something local t1 = socket.gettime() print("used time: "..t1-t0.."ms")
update: 如果对精度的要求不需要到毫秒级别,可以用自带的os模块.精度为0.01秒
[u]复制代码[/u] 代码如下:
local s = os.clock() local e = os.clock() print("used time"..e-s.." seconds")
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部