From 63b930ebc5060efecea0ec3acf7e5c93e4047864 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 8 Apr 2024 12:13:04 +0200 Subject: Tweak some test scripts --- tests/linda_perf.lua | 2 +- tests/protect_allocator.lua | 1 + tests/timer.lua | 12 +++++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua index c736428..61b8f05 100644 --- a/tests/linda_perf.lua +++ b/tests/linda_perf.lua @@ -1,5 +1,5 @@ local lanes = require "lanes" -lanes.configure{ with_timers = false, keepers_gc_threshold=20000 } +lanes.configure{ with_timers = false, keepers_gc_threshold=30000 } -- set TEST1, PREFILL1, FILL1, TEST2, PREFILL2, FILL2 from the command line diff --git a/tests/protect_allocator.lua b/tests/protect_allocator.lua index 6eead5d..5cbb1d8 100644 --- a/tests/protect_allocator.lua +++ b/tests/protect_allocator.lua @@ -46,6 +46,7 @@ for i = 1, COUNT do end -- wait for completion +print "wait for completion" linda:receive( linda.batched, "key", COUNT) print "waiting a bit more ..." linda:receive( 1, "foo") diff --git a/tests/timer.lua b/tests/timer.lua index ec23cee..73ecb93 100644 --- a/tests/timer.lua +++ b/tests/timer.lua @@ -18,13 +18,14 @@ end local T1= "1s" -- these keys can be anything... local T2= "5s" +local PING_DURATION = 20 local step= {} lanes.timer( linda, T1, 1.0, 1.0 ) step[T1]= 1.0 -PRINT( "\n*** Timers every second (not synced to wall clock) ***\n" ) +PRINT( "\n*** Starting 1s Timer (not synced to wall clock) ***\n" ) local v_first local v_last= {} -- { [channel]= num } @@ -46,14 +47,15 @@ while true do -- do not make measurements, first round is not 5secs due to wall clock adjustment T2_first_round= false else - assert( math.abs(v-v_last[channel]- step[channel]) < 0.02 ) + local dt = math.abs(v-v_last[channel]- step[channel]) + assert( dt < 0.02, "channel " .. channel .. " is late: " .. dt) end end if not v_first then v_first= v elseif v-v_first > 3.0 and (not step[T2]) then - PRINT( "\n*** Adding timers every 5 second (synced to wall clock) ***\n" ) + PRINT( "\n*** Starting 5s timer (synced to wall clock) ***\n" ) -- The first event can be in the past (just cut seconds down to 5s) -- @@ -63,7 +65,7 @@ while true do lanes.timer( linda, T2, date, 5.0 ) step[T2]= 5.0 - elseif v-v_first > 10 then -- exit condition + elseif v-v_first > PING_DURATION then -- exit condition break end v_last[channel]= v @@ -80,7 +82,7 @@ PRINT( "\n*** Listing timers ***\n" ) local r = lanes.timers() -- list of {linda, key, {}} for _,t in ipairs( r) do local linda, key, timer = t[1], t[2], t[3] - print( tostring( linda), key, timer[1], timer[2]) + print( tostring( linda), key, timer[1], timer[2]) end -- cgit v1.2.3-55-g6feb