forked from cloudwu/lua-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdump.lua
More file actions
73 lines (64 loc) · 1.53 KB
/
dump.lua
File metadata and controls
73 lines (64 loc) · 1.53 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
local snapshot = require "snapshot"
local snapshot_utils = require "snapshot_utils"
local S1 = snapshot()
local tmp = {
player = {
uid = 1,
camps = {
{campid = 1},
{campid = 2},
},
},
player2 = {
roleid = 2,
},
[6729207776230248443] = {
player1 = 1,
},
}
local a = {}
local c = {}
a.b = c
c.d = a
g_var = {}
local d = g_var
local msg = "bar"
local foo = function()
print(msg)
end
local co = coroutine.create(function ()
print("hello world")
end)
local S2 = snapshot()
print(snapshot_utils.dump(snapshot_utils.diff(S1,S2,true)))
S1 = nil
print("=========test ignore function=========")
local player1 = {tag = "player",id = 1}
local player2 = {tag = "player",id = 2}
local player11 = {tag = "player",id = 11}
local function ignore(obj)
if obj == _G or obj == debug.getregistry() then
return false
end
if type(obj) == "table" and obj.tag == "player" then
if obj.id > 10 then
return true
else
return false
end
end
return false
end
local S3 = snapshot(ignore)
print(snapshot_utils.dump(snapshot_utils.diff(S2,S3,true)))
S3 = nil
print("=========test refcount topN=========")
--snapshot_utils.omit_excess_refrence = false
local topN = 3
local S4 = snapshot()
print(snapshot_utils.dump(snapshot_utils.refcount_topN(topN,S4,true)))
S4 = nil
print("=========test tablecount topN=========")
local S5 = snapshot()
print(snapshot_utils.dump(snapshot_utils.tablecount_topN(topN,S5,true)))
S5 = nil