Lua常用库,垃圾回收

print("=================自带库=================")
-- string
-- table
print("=================时间=================")
-- 系统时间
print(os.time())
-- 自定义参数 得到时间
print(os.time({year = 2021, month = 3, day = 3}))

--  返回一个table
local nowTime = os.date("*t")
for k, v in pairs(nowTime) do
    print(k, v)
end
-- hour    11
-- min     43
-- wday    4
-- day     3
-- month   3
-- year    2021
-- sec     14
-- yday    62
-- isdst   false

print("=================数学运算=================")

-- 绝对值
math.abs(11)
-- 弧度转角度
math.deg(math.pi())

math.cos(math.pi())

math.floor(2.6)
math.ceil(5.2)

math.max(1, 2)
math.min(4, 5)
math.modf(1.2)
math.pow(2, 5)
-- 随机数
math.randomseed(os.time())
math.random(100)

math.sqrt( 4 )

print("=================路径=================")
print(package.path)

print("=================垃圾回收=================")

test = {id= 1, name = "123123"}
-- 垃圾回收关键字
-- collectgrabage
-- 获取当前lua占用内存数,K字节 用返回值 * 1024就可以得到具体的内存占用字节数

print(collectgarbage("count"))
-- 20.15234375

test = nil
--进行垃圾回收 理解有点像C# 的GC
collectgarbage("collect")

print(collectgarbage("count"))
20.51953125
19.3466796875

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值