Skip to content

Commit

Permalink
Remove hard-coded values from the IM benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
yiannist committed Nov 3, 2014
1 parent 61feb4f commit a3deedd
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions bench/im_bench/src/im_bench.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,44 @@ bench_args(_Version, _Conf) ->
[[]].

run(_, Slaves, Conf) ->
%% Setup a coordinator to know when the benchmark finished. This is done by
%% counting the number of loggers that have finished.
% Setup a coordinator to know when the benchmark finished. This is done by
% counting the number of loggers that have finished.
register(coordinator, self()),
%% Get the data dir in order to store the .csv output files there.
% Get the data dir in order to store the .csv output files there.
{_,DataDir} = lists:keyfind(datadir, 1, Conf),
%% Find the domain of the slave nodes (currently the same for everyone).
Slave1 = hd(Slaves),
[_SlaveName, SlaveHost] = string:tokens(atom_to_list(Slave1), "@"),
Domain = list_to_atom(SlaveHost),
launcher:start(3, 1, 3, 10, [Domain], 1),
logger:launch_latency("Bencherl_test", 1, 3, 8000, 10, 1, Domain, DataDir ++ "/"),
timer:sleep(60000), %XXX: Just to make sure that all clients have logged in.
toxic_client:launch(8000, 10, Domain),
timer:sleep(60000),
toxic_client:launch_traffic(8000, 10, Domain),
loop(10).
% Get the benchmark arguments from the configuration.
ClientNodes = filter_nodes(Slaves, "client"),
ServerNodes = filter_nodes(Slaves, "server"),
RouterNodes = filter_nodes(Slaves, "router"),
Domains = find_domains(Slaves),
% Start the benchmark on the different client domains.
launcher:start(length(ServerNodes) div length(RouterNodes), 1,
length(ServerNodes), length(ClientNodes), Domains, length(Domains)),
ClientDomains = find_domains(ClientNodes),
lists:foreach(fun(D) ->
logger:launch_latency("Bencherl_test", length(RouterNodes),
length(ServerNodes), 8000, length(ClientNodes), 1, D, DataDir ++ "/"),
timer:sleep(60000), %XXX: Just to make sure that all clients have logged in.
toxic_client:launch(8000, length(ClientNodes), D),
timer:sleep(60000),
toxic_client:launch_traffic(8000, length(ClientNodes), D)
end, ClientDomains),
loop(length(ClientNodes)).

%% filter_nodes/2 is a helper function that returns the nodes in the given list
%% whose name starts with the given prefix.
filter_nodes(Nodes, Prefix) ->
lists:filter(fun(N) ->
string:sub_string(atom_to_list(N), 1, string:len(Prefix)) == Prefix
end, Nodes).

%% find_domains/1 is a helper function that returns the different domains of
%% the given nodes.
find_domains(Nodes) ->
lists:usort(lists:map(fun(N) ->
[_N, H] = string:tokens(atom_to_list(N), "@"),
list_to_atom(H)
end, Nodes)).

%% loop/1 is a helper function that "prevents" run/3 from finishing until all
%% loggers have halted. Without this function the benchmark would finish after
Expand Down

0 comments on commit a3deedd

Please sign in to comment.