diff options
author | Björn-Egil Dahlberg <[email protected]> | 2015-05-11 10:18:22 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2015-05-11 10:18:22 +0200 |
commit | 56e271a7d63dbc76962c875e34fe3584e9110675 (patch) | |
tree | 64b03b6f7251cfe50f6684f083c261049bc56a88 /erts/emulator/test | |
parent | b6b4fd292a7f63ce9f28c0248b0d8e646971c926 (diff) | |
parent | e7335bb1197294ef6f5fb3ad73bb22b9343603be (diff) | |
download | otp-56e271a7d63dbc76962c875e34fe3584e9110675.tar.gz otp-56e271a7d63dbc76962c875e34fe3584e9110675.tar.bz2 otp-56e271a7d63dbc76962c875e34fe3584e9110675.zip |
Merge branch 'egil/fix-maps-erts_debug-size'
* egil/fix-maps-erts_debug-size:
erts: Fix erts_debug:size/1 for large Maps
erts: Simple test of erts_debug:size/1 of Maps
Diffstat (limited to 'erts/emulator/test')
-rw-r--r-- | erts/emulator/test/erts_debug_SUITE.erl | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/erts/emulator/test/erts_debug_SUITE.erl b/erts/emulator/test/erts_debug_SUITE.erl index e5c904cfb9..bc5928436f 100644 --- a/erts/emulator/test/erts_debug_SUITE.erl +++ b/erts/emulator/test/erts_debug_SUITE.erl @@ -71,6 +71,11 @@ test_size(Config) when is_list(Config) -> 4 = do_test_size(#{}), 32 = do_test_size(#{b => 2,c => 3,txt => "hello world"}), + true = do_test_size(maps:from_list([{I,I}||I<-lists:seq(1,256)])) >= map_size_lower_bound(256), + true = do_test_size(maps:from_list([{I,I}||I<-lists:seq(1,4096)])) >= map_size_lower_bound(4096), + true = do_test_size(maps:from_list([{I,I}||I<-lists:seq(1,254)])) >= map_size_lower_bound(254), + true = do_test_size(maps:from_list([{I,I}||I<-lists:seq(1,239)])) >= map_size_lower_bound(239), + %% Test internal consistency of sizes, but without testing %% exact sizes. Const = id(42), @@ -92,14 +97,14 @@ test_size(Config) when is_list(Config) -> %% Test shared data structures. do_test_size([ConsCell1|ConsCell1], - 3*ConsCellSz, - 2*ConsCellSz), + 3*ConsCellSz, + 2*ConsCellSz), do_test_size(fun() -> {ConsCell1,ConsCell2} end, - FunSz2 + 2*ConsCellSz, - FunSz2 + ConsCellSz), + FunSz2 + 2*ConsCellSz, + FunSz2 + ConsCellSz), do_test_size({SimplestFun,SimplestFun}, - 2*FunSz0+do_test_size({a,b}), - FunSz0+do_test_size({a,b})), + 2*FunSz0+do_test_size({a,b}), + FunSz0+do_test_size({a,b})), M = id(#{ "atom" => first, i => 0}), do_test_size([M,M#{ "atom" := other },M#{i := 42}],54,32), @@ -113,6 +118,13 @@ do_test_size(Term, FlatSz, Sz) -> FlatSz = erts_debug:flat_size(Term), Sz = erts_debug:size(Term). +map_size_lower_bound(N) -> + %% this est. is a bit lower that actual lower bound + %% number of internal nodes + T = (N - 1) div 15, + %% total words + 2 + 17 * T + 2 * N. + flat_size_big(Config) when is_list(Config) -> %% Build a term whose external size only fits in a big num (on 32-bit CPU). flat_size_big_1(16#11111111111111117777777777777777888889999, 0, 16#FFFFFFF). |