Skip to content

Commit

Permalink
Randomize subscription order in loadtest.
Browse files Browse the repository at this point in the history
  • Loading branch information
aforge committed Aug 7, 2020
1 parent 85156d4 commit fec808f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Binary file modified loadtest/tinode.beam
Binary file not shown.
7 changes: 6 additions & 1 deletion loadtest/tinode.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
%% directory.

-module(tinode).
-export([rand_user_secret/1]).
-export([rand_user_secret/1, shuffle/1]).

%% Produces a secret for use in basic login.
rand_user_secret({Pid, DynData}) ->
Expand All @@ -22,3 +22,8 @@ get_rand_secret() ->
5 -> "eve:eve123";
6 -> "frank:frank123"
end.

%% Shuffles a list randomly.
shuffle(L) ->
RandomList=[{rand:uniform(), X} || X <- L],
[X || {_,X} <- lists:sort(RandomList)].
8 changes: 7 additions & 1 deletion loadtest/tsung.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@
<dyn_variable name="subs" jsonpath="meta.sub[*].topic"/>
<websocket type="message" frame="text">{"get":{"id":"%%_baseid%%04","topic":"me","what":"sub"}}</websocket>
</request>
<setdynvars sourcetype="eval"
code="fun({Pid,DynVars})->
{ok,Subs}=ts_dynvars:lookup(subs,DynVars),
tinode:shuffle(Subs) end.">
<var name="shuffled_subs" />
</setdynvars>

<!-- main loop -->
<for from="1" to="100" incr="1" var="ctr">
<!-- Iterate over subscriptions -->
<foreach name="topicx" in="subs">
<foreach name="topicx" in="shuffled_subs">
<thinktime value="3" random="true"></thinktime>

<request subst="true">
Expand Down

0 comments on commit fec808f

Please sign in to comment.