aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-09-08 15:11:28 +0200
committerBjörn Gustavsson <[email protected]>2015-09-11 12:24:37 +0200
commit78eb4a1ff9cafe394e338abb7297a1199c5eba85 (patch)
tree39d2c6119c2e2825ae0f251bad3ecee9f44e4361 /lib/stdlib/test
parentc54430d8d47993ccc10651d2049961b4ab122a90 (diff)
downloadotp-78eb4a1ff9cafe394e338abb7297a1199c5eba85.tar.gz
otp-78eb4a1ff9cafe394e338abb7297a1199c5eba85.tar.bz2
otp-78eb4a1ff9cafe394e338abb7297a1199c5eba85.zip
base64_SUITE: Speed up roundtrip/1
Refactor roundtrip/1 into 4 test cases that can be run in parallel. Assuming that there are 4 cores available, the group of 4 test cases will run at roughly one fourth of the time for the original test case.
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/base64_SUITE.erl38
-rw-r--r--lib/stdlib/test/lists_SUITE.erl54
2 files changed, 29 insertions, 63 deletions
diff --git a/lib/stdlib/test/base64_SUITE.erl b/lib/stdlib/test/base64_SUITE.erl
index cca9b967d5..75eebba6c6 100644
--- a/lib/stdlib/test/base64_SUITE.erl
+++ b/lib/stdlib/test/base64_SUITE.erl
@@ -30,7 +30,8 @@
%% Test cases must be exported.
-export([base64_encode/1, base64_decode/1, base64_otp_5635/1,
base64_otp_6279/1, big/1, illegal/1, mime_decode/1,
- mime_decode_to_string/1, roundtrip/1]).
+ mime_decode_to_string/1,
+ roundtrip_1/1, roundtrip_2/1, roundtrip_3/1, roundtrip_4/1]).
init_per_testcase(_, Config) ->
Dog = test_server:timetrap(?t:minutes(4)),
@@ -50,10 +51,11 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[base64_encode, base64_decode, base64_otp_5635,
base64_otp_6279, big, illegal, mime_decode, mime_decode_to_string,
- roundtrip].
+ {group, roundtrip}].
groups() ->
- [].
+ [{roundtrip, [parallel],
+ [roundtrip_1, roundtrip_2, roundtrip_3, roundtrip_4]}].
init_per_suite(Config) ->
Config.
@@ -242,21 +244,33 @@ mime_decode_to_string(Config) when is_list(Config) ->
%%-------------------------------------------------------------------------
-roundtrip(Config) when is_list(Config) ->
- Sizes = lists:seq(1, 255) ++ lists:seq(2400-5, 2440),
- roundtrip_1(Sizes, []).
+roundtrip_1(Config) when is_list(Config) ->
+ do_roundtrip(1).
-roundtrip_1([NextSize|Sizes], Current) ->
+roundtrip_2(Config) when is_list(Config) ->
+ do_roundtrip(2).
+
+roundtrip_3(Config) when is_list(Config) ->
+ do_roundtrip(3).
+
+roundtrip_4(Config) when is_list(Config) ->
+ do_roundtrip(4).
+
+do_roundtrip(Offset) ->
+ Sizes = lists:seq(Offset, 255, 4) ++ lists:seq(2400-6+Offset, 2440, 4),
+ do_roundtrip_1(Sizes, []).
+
+do_roundtrip_1([NextSize|Sizes], Current) ->
Len = length(Current),
io:format("~p", [Len]),
- do_roundtrip(Current),
+ do_roundtrip_2(Current),
Next = random_byte_list(NextSize - Len, Current),
- roundtrip_1(Sizes, Next);
-roundtrip_1([], Last) ->
+ do_roundtrip_1(Sizes, Next);
+do_roundtrip_1([], Last) ->
io:format("~p", [length(Last)]),
- do_roundtrip(Last).
+ do_roundtrip_2(Last).
-do_roundtrip(List) ->
+do_roundtrip_2(List) ->
Bin = list_to_binary(List),
Base64Bin = base64:encode(List),
Base64Bin = base64:encode(Bin),
diff --git a/lib/stdlib/test/lists_SUITE.erl b/lib/stdlib/test/lists_SUITE.erl
index 5a447d58a4..a0f7fd2744 100644
--- a/lib/stdlib/test/lists_SUITE.erl
+++ b/lib/stdlib/test/lists_SUITE.erl
@@ -62,8 +62,7 @@
zip_unzip/1, zip_unzip3/1, zipwith/1, zipwith3/1,
filter_partition/1,
otp_5939/1, otp_6023/1, otp_6606/1, otp_7230/1,
- prefix/1, suffix/1, subtract/1, droplast/1, hof/1,
- split/1, concat/1]).
+ suffix/1, subtract/1, droplast/1, hof/1]).
%% Sort randomized lists until stopped.
%%
@@ -124,8 +123,8 @@ groups() ->
{tickets, [parallel], [otp_5939, otp_6023, otp_6606, otp_7230]},
{zip, [parallel], [zip_unzip, zip_unzip3, zipwith, zipwith3]},
{misc, [parallel], [reverse, member, dropwhile, takewhile,
- filter_partition, prefix, suffix, subtract,
- hof, split, concat]}
+ filter_partition, suffix, subtract,
+ hof]}
].
init_per_suite(Config) ->
@@ -2630,19 +2629,6 @@ otp_6606(Config) when is_list(Config) ->
?line L2 = lists:sort(L2),
ok.
-%% Test lists:prefix/2.
-prefix(Config) when is_list(Config) ->
- true = lists:prefix([], []),
- true = lists:prefix([], lists:seq(1, 10)),
- true = lists:prefix([a], [a,b]),
- true = lists:prefix(lists:seq(1, 10), lists:seq(1, 100)),
-
- false = lists:prefix([a], []),
- false = lists:prefix([a], [b]),
- false = lists:prefix([a], [b,a]),
-
- ok.
-
%% Test lists:suffix/2.
suffix(Config) when is_list(Config) ->
?line true = lists:suffix([], []),
@@ -2760,37 +2746,3 @@ hof(Config) when is_list(Config) ->
false = lists:all(fun(N) -> N rem 2 =:= 0 end, L),
ok.
-
-%% Test lists:split/2
-split(Config) when is_list(Config) ->
- Lens = lists:seq(0, 32),
- do_split(Lens),
-
- %% Error cases.
- {'EXIT',_} = (catch lists:split(a, [])),
- {'EXIT',_} = (catch lists:split(-1, [])),
- {'EXIT',_} = (catch lists:split(0, {a,b})),
- ok.
-
-do_split([Len|Lens]) ->
- List = [rand:uniform(1000) || _ <- lists:seq(1, Len)],
- do_split_1(0, Len, List),
- do_split(Lens);
-do_split([]) ->
- ok.
-
-do_split_1(N, Len, List) when N =:= Len + 1 ->
- {'EXIT',_} = (catch lists:split(N, List));
-do_split_1(N, Len, List) ->
- {A,B} = lists:split(N, List),
- List = A ++ B,
- N = length(A),
- LenB = length(B),
- LenB = Len - N,
- do_split_1(N+1, Len, List).
-
-%% Test lists:concat/1 mainly for coverage.
-concat(Config) when is_list(Config) ->
- S = integer_to_list(42) ++ "pi: " ++ float_to_list(math:pi()),
- S = lists:concat([42,pi,": ",math:pi()]),
- ok.