From 9694c72cae70fec65e19c8439a85d91cf21b39bf Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Tue, 23 Oct 2018 15:10:54 +0200 Subject: stdlib: Adjust binary bench to be faster When benchmarking releases before OTP-22 the binary:match function is very slow so it takes a long time to run the benchmarks. This commit makes the benchmark run for a shorter time which will make the results a bit less stable, but it will cut 1 hour from the benchmark regression so we will have to live with that. --- lib/stdlib/test/stdlib_bench_SUITE.erl | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/test/stdlib_bench_SUITE.erl b/lib/stdlib/test/stdlib_bench_SUITE.erl index b937eeb06a..436aa78a0f 100644 --- a/lib/stdlib/test/stdlib_bench_SUITE.erl +++ b/lib/stdlib/test/stdlib_bench_SUITE.erl @@ -38,7 +38,9 @@ groups() -> [norm_nfc_list, norm_nfc_deep_l, norm_nfc_binary, string_lexemes_list, string_lexemes_binary ]}, - {binary, [{repeat, 5}], + %% Only run 1 binary match repeat as it is very slow pre OTP-22. + %% The results seem to be stable enough anyway + {binary, [{repeat, 1}], [match_single_pattern_no_match, matches_single_pattern_no_match, matches_single_pattern_eventual_match, @@ -164,19 +166,19 @@ norm_data(Config) -> match_single_pattern_no_match(_Config) -> Binary = binary:copy(<<"ugbcfuysabfuqyfikgfsdalpaskfhgjsdgfjwsalp">>, 1000000), - comment(test(binary, match, [Binary, <<"o">>])). + comment(test(100, binary, match, [Binary, <<"o">>])). matches_single_pattern_no_match(_Config) -> Binary = binary:copy(<<"ugbcfuysabfuqyfikgfsdalpaskfhgjsdgfjwsalp">>, 1000000), - comment(test(binary, matches, [Binary, <<"o">>])). + comment(test(100, binary, matches, [Binary, <<"o">>])). matches_single_pattern_eventual_match(_Config) -> Binary = binary:copy(<<"ugbcfuysabfuqyfikgfsdalpaskfhgjsdgfjwsal\n">>, 1000000), - comment(test(binary, matches, [Binary, <<"\n">>])). + comment(test(100, binary, matches, [Binary, <<"\n">>])). matches_single_pattern_frequent_match(_Config) -> Binary = binary:copy(<<"abc\n">>, 1000000), - comment(test(binary, matches, [Binary, <<"abc">>])). + comment(test(100, binary, matches, [Binary, <<"abc">>])). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -233,9 +235,11 @@ list() -> random_byte_list(?SIZE). test(Mod, Fun, Args) -> - F = fun() -> loop(?N, Mod, Fun, Args) end, + test(?N, Mod, Fun, Args). +test(Iter, Mod, Fun, Args) -> + F = fun() -> loop(Iter, Mod, Fun, Args) end, {Time, ok} = timer:tc(fun() -> lspawn(F) end), - report_mfa(Time, Mod). + report_mfa(Iter, Time, Mod). loop(0, _M, _F, _A) -> garbage_collect(), ok; loop(N, M, F, A) -> @@ -248,8 +252,8 @@ lspawn(Fun) -> {'DOWN', Ref, process, Pid, Rep} -> Rep end. -report_mfa(Time, Mod) -> - Tps = round((?N*1000000)/Time), +report_mfa(Iter, Time, Mod) -> + Tps = round((Iter*1000000)/Time), ct_event:notify(#event{name = benchmark_data, data = [{suite, "stdlib_" ++ atom_to_list(Mod)}, {value, Tps}]}), -- cgit v1.2.3