Skip to content

Commit

Permalink
Merge branch 'bmk/megaco/20241218/meas_result_tweaking/OTP-19403'
Browse files Browse the repository at this point in the history
  • Loading branch information
bmk committed Jan 2, 2025
2 parents f4caf91 + baa9e58 commit ac7be0d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 47 deletions.
55 changes: 9 additions & 46 deletions lib/megaco/examples/meas/megaco_codec_meas.erl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ application.

-include_lib("kernel/include/file.hrl").

%% We are not mstone but the (mstone) lib module has general
%% functions that we can use.
-define(LIB, megaco_codec_mstone_lib).

-define(V3, v3).

-define(MEASURE_TIMEOUT, 100000). % 100 sec
Expand Down Expand Up @@ -179,49 +183,7 @@ display_system_info() ->


display_app_info() ->
display_megaco_info(),
display_asn1_info().

%% The instruction, nowarn_function, is because I can't figure out
%% how to suppress the warnings about
%% megaco_flex_scanner:is_enabled/0 and
%% megaco_flex_scanner:is_reentrant_enabled/0:
%%
%% "The pattern 'false' can never match the type 'true'"
%%
%% This is because the result of calling these function(s) is
%% basically decided at compile time (true or false).
-dialyzer({nowarn_function, display_megaco_info/0}).
display_megaco_info() ->
MI = megaco:module_info(),
{value, {attributes, Attr}} = lists:keysearch(attributes, 1, MI),
{value, {app_vsn, Ver}} = lists:keysearch(app_vsn, 1, Attr),
FlexStr =
case megaco_flex_scanner:is_enabled() of
true ->
case megaco_flex_scanner:is_reentrant_enabled() of
true ->
"reentrant flex";
false ->
"non-reentrant flex"
end;
false ->
"no flex"
end,
io:format("Megaco version: ~s (~s)~n", [Ver, FlexStr]).

display_asn1_info() ->
AI = megaco_ber_media_gateway_control_v1:info(),
Vsn =
case lists:keysearch(vsn, 1, AI) of
{value, {vsn, V}} when is_atom(V) ->
atom_to_list(V);
{value, {vsn, V}} when is_list(V) ->
V;
_ ->
"unknown"
end,
io:format("ASN.1 version: ~s~n", [Vsn]).
?LIB:display_app_info().


%% {MegaSec, Sec, MicroSec}
Expand Down Expand Up @@ -361,8 +323,8 @@ measure(_Factor, _Opts, _Dir, _Codec, _Conf, [], Res, _MCount) ->
io:format("~n[~s] Measurment on ~p messages:"
"~n Average:"
"~n Size: ~w bytes, "
"~n Encode: ~w microsec, "
"~n Decode: ~w microsec~n~n",
"~n Encode: ~w nanosec, "
"~n Decode: ~w nanosec~n~n",
[?FTS(), length(Res), Savg, Eavg, Davg]),

{ok, lists:reverse(Res)};
Expand Down Expand Up @@ -485,7 +447,8 @@ do_measure_codec(Factor, Codec, Func, Conf, Version, Bin, MCount) ->
{ok, Count} = measure_warmup(Codec, Func, Conf, Version, Bin, MCount),
Count2 = Count div Factor,
Res = timer:tc(?MODULE, do_measure_codec_loop,
[Codec, Func, Conf, Version, Bin, Count2, dummy]),
[Codec, Func, Conf, Version, Bin, Count2, dummy],
nanosecond),
case Res of
{Time, {ok, M}} ->
exit({measure_result, {M, Count2, Time}});
Expand Down
9 changes: 8 additions & 1 deletion lib/megaco/examples/meas/megaco_codec_mstone_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,14 @@ display_app_info() ->
display_megaco_info() ->
MI = megaco:module_info(),
{value, {attributes, Attr}} = lists:keysearch(attributes, 1, MI),
{value, {app_vsn, Ver}} = lists:keysearch(app_vsn, 1, Attr),
{value, {app_vsn, MVer}} = lists:keysearch(app_vsn, 1, Attr),
Ver =
case MVer of
"megaco-" ++ VStr ->
VStr;
_ ->
MVer
end,
io:format("Megaco version: ~s~n", [Ver]).

display_asn1_info() ->
Expand Down

0 comments on commit ac7be0d

Please sign in to comment.