/benchmarks/tsung_utils.erl

http://github.com/AF83/ucengine · Erlang · 22 lines · 17 code · 3 blank · 2 comment · 2 complexity · a3fc5f4fdd292d74e5f9bec1468741be MD5 · raw file

  1. -module(tsung_utils).
  2. -export([extract_last_timestamp/1]).
  3. extract_last_timestamp({_Pid, DynData}) ->
  4. {ok, Events} = ts_dynvars:lookup(events, DynData),
  5. if
  6. Events == undefined; Events == [] ->
  7. % Retry with the same timestamp
  8. case ts_dynvars:lookup(last, DynData) of
  9. {ok, LastTimestamp} ->
  10. LastTimestamp;
  11. % Or the first timestamp
  12. false ->
  13. 0
  14. end;
  15. true ->
  16. {struct, EventAttributes} = lists:last(Events),
  17. {<<"datetime">>, Datetime} = lists:keyfind(<<"datetime">>, 1, EventAttributes),
  18. integer_to_list(Datetime + 1)
  19. end.