diff options
Diffstat (limited to 'lib/stdlib/test/dets_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/dets_SUITE.erl | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/lib/stdlib/test/dets_SUITE.erl b/lib/stdlib/test/dets_SUITE.erl index c50a2d5baf..5a19717c28 100644 --- a/lib/stdlib/test/dets_SUITE.erl +++ b/lib/stdlib/test/dets_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2021. All Rights Reserved. +%% Copyright Ericsson AB 1996-2023. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ otp_5487/1, otp_6206/1, otp_6359/1, otp_4738/1, otp_7146/1, otp_8070/1, otp_8856/1, otp_8898/1, otp_8899/1, otp_8903/1, otp_8923/1, otp_9282/1, otp_11245/1, otp_11709/1, otp_13229/1, - otp_13260/1, otp_13830/1]). + otp_13260/1, otp_13830/1, receive_optimisation/1]). -export([dets_dirty_loop/0]). @@ -94,7 +94,7 @@ all() -> insert_new, repair_continuation, otp_5487, otp_6206, otp_6359, otp_4738, otp_7146, otp_8070, otp_8856, otp_8898, otp_8899, otp_8903, otp_8923, otp_9282, otp_11245, otp_11709, - otp_13229, otp_13260, otp_13830 + otp_13229, otp_13260, otp_13830, receive_optimisation ]. groups() -> @@ -3492,6 +3492,34 @@ otp_13830(Config) -> {ok, Tab} = dets:open_file(Tab, [{file, File}, {version, default}]), ok = dets:close(Tab). +receive_optimisation(Config) -> + Tab = dets_receive_optimisation_test, + FName = filename(Tab, Config), + + % Spam message box + lists:foreach(fun(_) -> self() ! {spam, it} end, lists:seq(1, 1_000_000)), + + {ok, _} = dets:open_file(Tab,[{file, FName}]), + ok = dets:insert(Tab,{one, record}), + + StartTime = os:system_time(millisecond), + + % We expect one thousand of simple lookups to finish in one second + Lookups = 1000, + Timeout = 1000, + Loop = fun Loop(N) when N =< 0 -> ok; + Loop(N) -> + Now = os:system_time(millisecond), + (Now - StartTime > Timeout) andalso throw({timeout_after, Lookups - N}), + [{one, record}] = dets:lookup(Tab, one), + Loop(N-1) + end, + + ok = Loop(Lookups), + + ok = dets:close(Tab), + ok = file:delete(FName). + %% %% Parts common to several test cases %% |