diff options
| -rw-r--r-- | tests/linda_perf.lua | 2 | ||||
| -rw-r--r-- | tests/protect_allocator.lua | 1 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | local lanes = require "lanes" | 1 | local lanes = require "lanes" |
| 2 | lanes.configure{ with_timers = false, keepers_gc_threshold=20000 } | 2 | lanes.configure{ with_timers = false, keepers_gc_threshold=30000 } |
| 3 | 3 | ||
| 4 | -- set TEST1, PREFILL1, FILL1, TEST2, PREFILL2, FILL2 from the command line | 4 | -- set TEST1, PREFILL1, FILL1, TEST2, PREFILL2, FILL2 from the command line |
| 5 | 5 | ||
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 | |||
| 46 | end | 46 | end |
| 47 | 47 | ||
| 48 | -- wait for completion | 48 | -- wait for completion |
| 49 | print "wait for completion" | ||
| 49 | linda:receive( linda.batched, "key", COUNT) | 50 | linda:receive( linda.batched, "key", COUNT) |
| 50 | print "waiting a bit more ..." | 51 | print "waiting a bit more ..." |
| 51 | linda:receive( 1, "foo") | 52 | 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 | |||
| 18 | 18 | ||
| 19 | local T1= "1s" -- these keys can be anything... | 19 | local T1= "1s" -- these keys can be anything... |
| 20 | local T2= "5s" | 20 | local T2= "5s" |
| 21 | local PING_DURATION = 20 | ||
| 21 | 22 | ||
| 22 | local step= {} | 23 | local step= {} |
| 23 | 24 | ||
| 24 | lanes.timer( linda, T1, 1.0, 1.0 ) | 25 | lanes.timer( linda, T1, 1.0, 1.0 ) |
| 25 | step[T1]= 1.0 | 26 | step[T1]= 1.0 |
| 26 | 27 | ||
| 27 | PRINT( "\n*** Timers every second (not synced to wall clock) ***\n" ) | 28 | PRINT( "\n*** Starting 1s Timer (not synced to wall clock) ***\n" ) |
| 28 | 29 | ||
| 29 | local v_first | 30 | local v_first |
| 30 | local v_last= {} -- { [channel]= num } | 31 | local v_last= {} -- { [channel]= num } |
| @@ -46,14 +47,15 @@ while true do | |||
| 46 | -- do not make measurements, first round is not 5secs due to wall clock adjustment | 47 | -- do not make measurements, first round is not 5secs due to wall clock adjustment |
| 47 | T2_first_round= false | 48 | T2_first_round= false |
| 48 | else | 49 | else |
| 49 | assert( math.abs(v-v_last[channel]- step[channel]) < 0.02 ) | 50 | local dt = math.abs(v-v_last[channel]- step[channel]) |
| 51 | assert( dt < 0.02, "channel " .. channel .. " is late: " .. dt) | ||
| 50 | end | 52 | end |
| 51 | end | 53 | end |
| 52 | 54 | ||
| 53 | if not v_first then | 55 | if not v_first then |
| 54 | v_first= v | 56 | v_first= v |
| 55 | elseif v-v_first > 3.0 and (not step[T2]) then | 57 | elseif v-v_first > 3.0 and (not step[T2]) then |
| 56 | PRINT( "\n*** Adding timers every 5 second (synced to wall clock) ***\n" ) | 58 | PRINT( "\n*** Starting 5s timer (synced to wall clock) ***\n" ) |
| 57 | 59 | ||
| 58 | -- The first event can be in the past (just cut seconds down to 5s) | 60 | -- The first event can be in the past (just cut seconds down to 5s) |
| 59 | -- | 61 | -- |
| @@ -63,7 +65,7 @@ while true do | |||
| 63 | lanes.timer( linda, T2, date, 5.0 ) | 65 | lanes.timer( linda, T2, date, 5.0 ) |
| 64 | step[T2]= 5.0 | 66 | step[T2]= 5.0 |
| 65 | 67 | ||
| 66 | elseif v-v_first > 10 then -- exit condition | 68 | elseif v-v_first > PING_DURATION then -- exit condition |
| 67 | break | 69 | break |
| 68 | end | 70 | end |
| 69 | v_last[channel]= v | 71 | v_last[channel]= v |
| @@ -80,7 +82,7 @@ PRINT( "\n*** Listing timers ***\n" ) | |||
| 80 | local r = lanes.timers() -- list of {linda, key, {}} | 82 | local r = lanes.timers() -- list of {linda, key, {}} |
| 81 | for _,t in ipairs( r) do | 83 | for _,t in ipairs( r) do |
| 82 | local linda, key, timer = t[1], t[2], t[3] | 84 | local linda, key, timer = t[1], t[2], t[3] |
| 83 | print( tostring( linda), key, timer[1], timer[2]) | 85 | print( tostring( linda), key, timer[1], timer[2]) |
| 84 | end | 86 | end |
| 85 | 87 | ||
| 86 | 88 | ||
