-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.uv.lua
More file actions
43 lines (32 loc) · 1.01 KB
/
test.uv.lua
File metadata and controls
43 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
print(string.rep("-", 64))
uv = require "uv"
local function demo(str)
local f = loadstring("return "..str)
print(str, f())
end
print(string.rep("-", 64))
print("utilities")
print(string.rep("-", 64))
demo "uv.now()"
demo "uv.hrtime()"
demo "uv.uptime()"
demo "uv.loadavg()"
demo "uv.get_process_title()"
demo "uv.get_free_memory()"
demo "uv.get_total_memory()"
local cpus = { uv.cpu_info() }
for i, cpu in ipairs(cpus) do
print(string.format("cpu %d: model %s speed %d times.user %f times.nice %f times.sys %f times.idle %f times.irq %f", i, cpu.model, cpu.speed, cpu.times.user, cpu.times.nice, cpu.times.sys, cpu.times.idle, cpu.times.irq))
end
print(string.rep("-", 64))
print("network")
print(string.rep("-", 64))
local addresses = { uv.interface_addresses() }
for i, a in pairs(addresses) do
print(string.format("interface %d: family: %s address: %s interface: %s internal:", i, a.family, a.address, a.interface), a.internal)
end
print(string.rep("-", 64))
print("timer")
print(string.rep("-", 64))
--]=]
print("ok")