PageRenderTime 242ms CodeModel.GetById 110ms app.highlight 3ms RepoModel.GetById 78ms app.codeStats 0ms

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