-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflush.lua
More file actions
52 lines (39 loc) · 815 Bytes
/
flush.lua
File metadata and controls
52 lines (39 loc) · 815 Bytes
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
44
45
46
47
48
49
50
51
52
local Co = require "internal.Co"
local Timer = require "internal.Timer"
local TCP = require "internal.TCP"
local UDP = require "internal.UDP"
local sys = require "sys"
local now = sys.now
local USAGE = [[
flush [COMMAND]:
all - flush all cache.
]]
local DONE = [[
clean Co space : %.6f/Sec
clean TCP space : %.6f/Sec
clean UDP space : %.6f/Sec
clean Timer space : %.6f/Sec
Done.]]
return function (cmd)
if cmd ~= 'all' then
return USAGE
end
local start, co, tcp, udp, timer
-- 协程
start = now()
Co.flush()
co = now() - start
-- TCP
start = now()
TCP.flush()
tcp = now() - start
-- UDP
start = now()
UDP.flush()
udp = now() - start
-- 定时器
start = now()
Timer.flush()
timer = now() - start
return string.format(DONE, co, tcp, udp, timer)
end