aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-12-22 14:48:07 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-12-22 14:48:07 -0300
commite2cc179454c6aa6cde5f98954bd3783e0d5d53a3 (patch)
tree1770fb2eded15ad53211693b19eb2a8698cbf192 /testes
parentad0ea7813b39e76b377983138ca995189e22054f (diff)
downloadlua-e2cc179454c6aa6cde5f98954bd3783e0d5d53a3.tar.gz
lua-e2cc179454c6aa6cde5f98954bd3783e0d5d53a3.tar.bz2
lua-e2cc179454c6aa6cde5f98954bd3783e0d5d53a3.zip
New option "setparms" for 'collectgarbage'
The generational mode also uses the parameters for the incremental mode in its major collections, so it should be easy to change those parameters without having to change the GC mode.
Diffstat (limited to 'testes')
-rw-r--r--testes/gc.lua11
-rw-r--r--testes/gengc.lua5
2 files changed, 10 insertions, 6 deletions
diff --git a/testes/gc.lua b/testes/gc.lua
index d7e0c4ff..61b5da9c 100644
--- a/testes/gc.lua
+++ b/testes/gc.lua
@@ -27,17 +27,20 @@ end
27 27
28-- test weird parameters to 'collectgarbage' 28-- test weird parameters to 'collectgarbage'
29do 29do
30 collectgarbage("incremental")
31 local opause = collectgarbage("setparam", "pause", 100)
32 local ostepmul = collectgarbage("setparam", "stepmul", 100)
30 local t = {0, 2, 10, 90, 500, 5000, 30000, 0x7ffffffe} 33 local t = {0, 2, 10, 90, 500, 5000, 30000, 0x7ffffffe}
31 for i = 1, #t do 34 for i = 1, #t do
32 local p = t[i] 35 collectgarbage("setparam", "pause", t[i])
33 for j = 1, #t do 36 for j = 1, #t do
34 local m = t[j] 37 collectgarbage("setparam", "stepmul", t[j])
35 collectgarbage("incremental", p, m)
36 collectgarbage("step") 38 collectgarbage("step")
37 end 39 end
38 end 40 end
39 -- restore original parameters 41 -- restore original parameters
40 collectgarbage("incremental", 200, 300) 42 collectgarbage("setparam", "pause", opause)
43 collectgarbage("setparam", "stepmul", ostepmul)
41 collectgarbage() 44 collectgarbage()
42end 45end
43 46
diff --git a/testes/gengc.lua b/testes/gengc.lua
index d708d7fc..cae07285 100644
--- a/testes/gengc.lua
+++ b/testes/gengc.lua
@@ -163,14 +163,15 @@ assert(collectgarbage'isrunning')
163 163
164 164
165do print"testing stop-the-world collection" 165do print"testing stop-the-world collection"
166 collectgarbage("incremental", nil, 0) 166 local step = collectgarbage("setparam", "stepsize", 0);
167 collectgarbage("incremental")
167 168
168 -- each step does a complete cycle 169 -- each step does a complete cycle
169 assert(collectgarbage("step")) 170 assert(collectgarbage("step"))
170 assert(collectgarbage("step")) 171 assert(collectgarbage("step"))
171 172
172 -- back to default value 173 -- back to default value
173 collectgarbage("incremental", nil, 200) 174 collectgarbage("setparam", "stepsize", step);
174end 175end
175 176
176collectgarbage(oldmode) 177collectgarbage(oldmode)