Skip to content

Commit

Permalink
More perf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
essen committed Jan 6, 2025
1 parent ffdab5b commit cb5b628
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions test/ws_perf_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,27 @@
%% ct.

all() ->
[{group, http}, {group, h2c}].
[{group, ascii}, {group, mixed}, {group, japanese}].

groups() ->
cowboy_test:common_groups(ct_helper:all(?MODULE), no_parallel).

init_per_suite(Config) ->
{ok, LargeText} = file:read_file(filename:join(config(data_dir, Config), "grok_segond.txt")),
[{large_text, LargeText}|Config].

end_per_suite(_Config) ->
ok.
CommonGroups = cowboy_test:common_groups(ct_helper:all(?MODULE), no_parallel),
SubGroups = [G || G = {GN, _, _} <- CommonGroups,
GN =:= http orelse GN =:= h2c],
[
{ascii, [], SubGroups},
{mixed, [], SubGroups},
{japanese, [], SubGroups}
].

init_per_group(Name=http, Config) ->
ct:pal("Websocket over cleartext HTTP/1.1"),
ct:pal("Websocket over cleartext HTTP/1.1 (~s)",
[config(text_data_filename, Config)]),
cowboy_test:init_http(Name, #{
env => #{dispatch => init_dispatch(Config)}
}, [{flavor, vanilla}|Config]);
init_per_group(Name=h2c, Config) ->
ct:pal("Websocket over cleartext HTTP/2"),
ct:pal("Websocket over cleartext HTTP/2 (~s)",
[config(text_data_filename, Config)]),
Config1 = cowboy_test:init_http(Name, #{
connection_window_margin_size => 64*1024,
enable_connect_protocol => true,
Expand All @@ -52,7 +54,17 @@ init_per_group(Name=h2c, Config) ->
stream_window_data_threshold => 1024,
stream_window_margin_size => 64*1024
}, [{flavor, vanilla}|Config]),
lists:keyreplace(protocol, 1, Config1, {protocol, http2}).
lists:keyreplace(protocol, 1, Config1, {protocol, http2});
init_per_group(ascii, Config) ->
init_text_data("ascii.txt", Config);
init_per_group(mixed, Config) ->
init_text_data("grok_segond.txt", Config);
init_per_group(japanese, Config) ->
init_text_data("japanese.txt", Config).

init_text_data(Filename, Config) ->
{ok, Text} = file:read_file(filename:join(config(data_dir, Config), Filename)),
[{text_data, Text}, {text_data_filename, Filename}|Config].

end_per_group(Name, _Config) ->
cowboy_test:stop_group(Name).
Expand Down Expand Up @@ -187,6 +199,10 @@ repeat_text_16384B(Config) ->
doc("Send and receive a 16384B text frame 1000 times."),
do_full(Config, repeat, 1000, text, 16384).

%repeat_text_16384B_10K(Config) ->
% doc("Send and receive a 16384B text frame 10000 times."),
% do_full(Config, repeat, 10000, text, 16384).

do_full(Config, What, Num, FrameType, FrameSize) ->
{ok, ConnPid, StreamRef} = do_gun_open_ws(Config),
FrameData = case FrameType of
Expand All @@ -209,7 +225,7 @@ do_full1(ConnPid, StreamRef, Num, FrameType, FrameData) ->
%% Internal.

do_text_data(Config, FrameSize) ->
do_text_data1(config(large_text, Config), FrameSize).
do_text_data1(config(text_data, Config), FrameSize).

do_text_data1(LargeText, FrameSize) when byte_size(LargeText) >= FrameSize ->
binary:part(LargeText, 0, FrameSize);
Expand Down

0 comments on commit cb5b628

Please sign in to comment.