[Tsung] Calling a %%module:function%% multiple times with same Pid
Pablo Polvorin
ppolv at yahoo.com.ar
Wed May 21 01:01:19 CEST 2008
Hi Martin,
>>A workaround would be to allow putting the result
>>of a %%module:function%% call into a dynamic
>>variable, that could then be used to refer to the
>>same data later
there is a new feature available in svn trunk that let
you do exactly that. I think it isn't documented yet,
but take a look at
http://svn.process-one.net/tsung/trunk/examples/http_setdynvars.xml.in
for some sample usage.
Basically, all you need to do is add a setdynvar
element to your session:
<setdynvars sourcetype="random_number" start="3"
end="32">
<var name="rndint" />
</setdynvars>
That defines a variable named rndint, that can be used
as many times as you need (in that session).
<request subst="true"><http>...%%_rndint%%...
<request subst="true"><http>...%%_rndint%%...
(look at the samples, there are other source types
availables other than random_number, including erlang
callbacks)
cheers,
pablo
--- "Stein, Martin" <martin.stein at sap.com> escribió:
> I am using the %%module:function%% feature to
> generate one random
> number, that is subsequently reused.
>
>
>
> Basically I have one call to generate a new ID that
> is returned and
> stored in an ETS table with the Pid. (putCID)
>
> Another call retrieves the ID for the given PID, and
> the last call
> deletes the item in the ETS table.
>
>
>
> This is done, so that a generated random ID can be
> used a couple of
> times in one session.
>
>
>
> <session>
>
> <request><http>...%%ran500:putCID%%...
>
> < request><http>...%%ran500:getCar%%...
>
> <request><http>...%%ran500:getCar%%...
>
> <request><http>...%%ran500:deleteCID%%...
>
> </session>
>
>
>
> The code for the functions is straightforward and at
> the end of the
> message.
>
>
>
> When I run with 10 users/sec things work fine, but
> with more users this
> fails.
>
>
>
> ts_client:(5:<0.65.0>) Stop in state wait_ack,
> reason= {badarg,
>
>
> [{ets,
>
>
> delete,
>
>
> [tsungtest,
>
>
> <0.65.0>]},
>
>
> {ran500,
>
>
> deleteCID,
>
>
> 1},
>
>
> {ts_search,
>
>
> extract_function,
>
>
> 5},
>
>
> {ts_search,
>
>
> subst,2},
>
>
> {ts_http,
>
>
> subst,2},
>
>
> {ts_http,
>
>
> add_dynparams,
>
>
> 4},
>
>
> {ts_client,
>
>
> handle_next_request,
>
>
> 2},
>
>
> {gen_fsm,
>
>
> handle_msg,
>
>
> 7}]}
>
>
>
>
>
> I assume that in one session the Pid would be the
> same throughout the
> session. So the 4 calls to my ran500 module should
> all be made with the
> same Pid in the argument, even at higher loads.
>
>
>
> A workaround would be to allow putting the result of
> a
> %%module:function%% call into a dynamic variable,
> that could then be
> used to refer to the same data later. Maybe the
> <dyn_variable> could be
> extended to a <dyn_function> that calls a function
> and stores the
> result?
>
>
>
> Thanks!
>
>
>
>
>
> ------------------------------------- code
>
>
>
> %%% File : ran500.erl
>
> -module(ran500).
>
> -export([putCID/1, getCar/1, deleteCID/1]).
>
>
>
> randomCar() ->
>
> io_lib:format("~p.VCar", [random:uniform(500)]).
>
>
>
> % put generated ID into ETS
>
> putCID({Pid, _DynData}) ->
>
> case ets:info(tsungtest) of
>
> undefined ->
>
> ets:new(tsungtest, [named_table,
> public]);
>
> _Otherwise -> ok
>
> end,
>
> Car = randomCar(),
>
> true = ets:insert(tsungtest, {Pid, Car}),
>
> Car.
>
>
>
> % get car for cid in Dyndata
>
> getCar({Pid, _DynData}) ->
>
> [{_PidKey, Carname}] = ets:lookup(tsungtest,
> Pid),
>
> Carname.
>
>
>
=== message truncated ===>
_______________________________________________
> Tsung-users mailing list
> Tsung-users at lists.process-one.net
>
https://lists.process-one.net/mailman/listinfo/tsung-users
>
Yahoo! Deportes Beta
¡No te pierdas lo último sobre el torneo clausura 2008! Enterate aquí http://deportes.yahoo.com
More information about the Tsung-users
mailing list