diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-07 10:07:44 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-07 10:07:44 +0200 |
commit | 6a2d1112c3cf64b46f7c60d7878d5cc8101fc5cd (patch) | |
tree | edc830d4507fc8b05c2202dcebb499d16563cb3d /deep_test | |
parent | 57ca292c8844e566184e3f7e5c98fa98991684bd (diff) | |
download | lanes-6a2d1112c3cf64b46f7c60d7878d5cc8101fc5cd.tar.gz lanes-6a2d1112c3cf64b46f7c60d7878d5cc8101fc5cd.tar.bz2 lanes-6a2d1112c3cf64b46f7c60d7878d5cc8101fc5cd.zip |
Debug code to help track linda gc during keeper operation
Diffstat (limited to 'deep_test')
-rw-r--r-- | deep_test/deeptest.lua | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/deep_test/deeptest.lua b/deep_test/deeptest.lua index 99cf1e4..250eb98 100644 --- a/deep_test/deeptest.lua +++ b/deep_test/deeptest.lua | |||
@@ -1,6 +1,8 @@ | |||
1 | local lanes = require("lanes").configure{ with_timers = false} | 1 | local lanes = require("lanes").configure{ with_timers = false} |
2 | local l = lanes.linda "my linda" | 2 | local l = lanes.linda "my linda" |
3 | 3 | ||
4 | local table_unpack = table.unpack or unpack -- Lua 5.1 support | ||
5 | |||
4 | -- we will transfer userdata created by this module, so we need to make Lanes aware of it | 6 | -- we will transfer userdata created by this module, so we need to make Lanes aware of it |
5 | local dt = lanes.require "deep_test" | 7 | local dt = lanes.require "deep_test" |
6 | 8 | ||
@@ -93,24 +95,44 @@ if DEEP then | |||
93 | print "================================================================" | 95 | print "================================================================" |
94 | print "DEEP" | 96 | print "DEEP" |
95 | local d = dt.new_deep(nupvals) | 97 | local d = dt.new_deep(nupvals) |
96 | if DEEP == "gc" then | 98 | if type(DEEP) == "string" then |
97 | local thrasher = function(repeat_, size_) | 99 | local gc_tests = { |
98 | print "in thrasher" | 100 | thrasher = function(repeat_, size_) |
99 | -- result is a table of repeat_ tables, each containing size_ entries | 101 | print "in thrasher" |
100 | local result = {} | 102 | -- result is a table of repeat_ tables, each containing size_ entries |
101 | for i = 1, repeat_ do | 103 | local result = {} |
102 | local batch_values = {} | 104 | for i = 1, repeat_ do |
103 | for j = 1, size_ do | 105 | local batch_values = {} |
104 | table.insert(batch_values, j) | 106 | for j = 1, size_ do |
107 | table.insert(batch_values, j) | ||
108 | end | ||
109 | table.insert(result, batch_values) | ||
110 | end | ||
111 | print "thrasher done" | ||
112 | return result | ||
113 | end, | ||
114 | stack_abuser = function(repeat_, size_) | ||
115 | print "in stack_abuser" | ||
116 | for i = 1, repeat_ do | ||
117 | local batch_values = {} | ||
118 | for j = 1, size_ do | ||
119 | table.insert(batch_values, j) | ||
120 | end | ||
121 | -- return size_ values | ||
122 | local _ = table_unpack(batch_values) | ||
105 | end | 123 | end |
106 | table.insert(result, batch_values) | 124 | print "stack_abuser done" |
125 | return result | ||
107 | end | 126 | end |
108 | print "thrasher done" | 127 | } |
109 | return result | ||
110 | end | ||
111 | -- have the object call the function from inside one of its functions, to detect if it gets collected from there (while in use!) | 128 | -- have the object call the function from inside one of its functions, to detect if it gets collected from there (while in use!) |
112 | local r = d:invoke(thrasher, REPEAT or 10, SIZE or 10) | 129 | local testf = gc_tests[DEEP] |
113 | print("invoke -> ", tostring(r)) | 130 | if testf then |
131 | local r = d:invoke(gc_tests[DEEP], REPEAT or 10, SIZE or 10) | ||
132 | print("invoke -> ", tostring(r)) | ||
133 | else | ||
134 | print("unknown test '" .. DEEP .. "'") | ||
135 | end | ||
114 | else | 136 | else |
115 | performTest(d) | 137 | performTest(d) |
116 | end | 138 | end |