diff options
author | Dan Gudmundsson <[email protected]> | 2017-09-26 10:14:54 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2017-09-26 10:14:54 +0200 |
commit | 3c23f2c6335d8586aca1efb9da6d20f00a8840fd (patch) | |
tree | 51cd6b964697db8b65abdc617ae8204fa807cc13 /lib/stdlib/test/unicode_util_SUITE.erl | |
parent | 1b18005cf26957a736abac4ff05e300fbda7c075 (diff) | |
parent | 7554cf21e7911e5a143b5219982639908f04b1fc (diff) | |
download | otp-3c23f2c6335d8586aca1efb9da6d20f00a8840fd.tar.gz otp-3c23f2c6335d8586aca1efb9da6d20f00a8840fd.tar.bz2 otp-3c23f2c6335d8586aca1efb9da6d20f00a8840fd.zip |
Merge branch 'dgud/stdlib/unicode-string-bench'
* dgud/stdlib/unicode-string-bench:
stdlib: Add unicode string benchmarks
Diffstat (limited to 'lib/stdlib/test/unicode_util_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/unicode_util_SUITE.erl | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/stdlib/test/unicode_util_SUITE.erl b/lib/stdlib/test/unicode_util_SUITE.erl index 03c24c7027..7dba0a2fd0 100644 --- a/lib/stdlib/test/unicode_util_SUITE.erl +++ b/lib/stdlib/test/unicode_util_SUITE.erl @@ -29,7 +29,9 @@ get/1, count/1]). --export([debug/0, id/1, bin_split/1, uc_loaded_size/0]). +-export([debug/0, id/1, bin_split/1, uc_loaded_size/0, + time_count/4 %% Used by stdlib_bench_SUITE + ]). suite() -> [{ct_hooks,[ts_install_cth]}, @@ -323,7 +325,7 @@ do_measure(Config) -> File = DataDir ++ "/NormalizationTest.txt", {ok, Bin} = file:read_file(File), Do = fun(Func, Mode) -> - {N, Mean, Stddev, Res} = time_count(Func, Mode, Bin), + {N, Mean, Stddev, Res} = time_count(Func, Mode, Bin, 10), io:format("~4w ~6w ~.10w ~.6wms ±~.2wms #~.2w~n", [Func, Mode, Res, Mean div 1000, Stddev div 1000, N]) end, @@ -345,19 +347,19 @@ uc_loaded_size([_|Rest]) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -time_count(Fun, Mode, Bin) -> +time_count(Fun, Mode, Bin, Repeat) -> timer:sleep(100), %% Let emulator catch up and clean things before test runs Self = self(), Pid = spawn_link(fun() -> Str = mode(Mode, Bin), - Self ! {self(),do_count(0,0,0, Fun, Str, undefined)} + Self ! {self(),do_count(0,0,0, Fun, Str, undefined, Repeat)} end), receive {Pid,Msg} -> Msg end. -do_count(N,Sum,SumSq, Fun, Str, _) when N < 10 -> +do_count(N,Sum,SumSq, Fun, Str, _, Repeat) when N < Repeat -> {Time, Res} = do_count(Fun, Str), - do_count(N+1,Sum+Time,SumSq+Time*Time, Fun, Str, Res); -do_count(N,Sum,SumSq, _, _, Res) -> + do_count(N+1,Sum+Time,SumSq+Time*Time, Fun, Str, Res, Repeat); +do_count(N,Sum,SumSq, _, _, Res, _) -> Mean = round(Sum / N), Stdev = round(math:sqrt((SumSq - (Sum*Sum/N))/(N - 1))), {N, Mean, Stdev, Res}. |