Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 51 lines (42 sloc) 1.61 KB
#!/usr/bin/env escript
%% -*- erlang -*-
%%! +K true
-mode(compile).
main([LogFile, SecondsStr, Server, PortStr, ClientsStr]) ->
Port = list_to_integer(PortStr),
Clients = list_to_integer(ClientsStr),
Seconds = list_to_integer(SecondsStr),
code:add_paths([
"deps/eleveldb/ebin",
"ebin"]),
io:format("Running test with ~p clients for ~p seconds~n"
"Data File: ~p~n",
[Clients, Seconds, LogFile]),
{ok, _} = wsdemo_logger:start_link(LogFile),
spawn(fun() -> report_loop(erlang:now(), Seconds) end),
{ok, _} = wsdemo_stats:start_link(Server, Port, Clients),
io:format("Running~n", []),
timer:sleep(timer:seconds(Seconds)),
io:format("Finished~n", []),
wsdemo_logger:close(),
ok;
main([LogFile, SecondsStr, ClientsStr]) ->
main([LogFile, SecondsStr, "localhost", "8000", ClientsStr]);
main(_) ->
usage().
usage() ->
io:format("usage: ~n"
"runtest LogFile::string() Seconds::integer() ClientCount::integer() | ~n"
"runtest LogFile::string() Seconds::integer() Server::string() Port::integer() ClientCount::integer()~n", []).
report_loop(Start, Seconds) ->
case whereis(wsdemo_logger) of
undefined ->
timer:sleep(10),
report_loop(Start, Seconds);
Pid ->
Elapsed = trunc(timer:now_diff(erlang:now(), Start) / 1000000),
{message_queue_len, Len} = process_info(Pid, message_queue_len),
io:format("logger queue: ~w Elapsed: ~ws of ~ws ~n", [Len,Elapsed, Seconds]),
timer:sleep(30000),
report_loop(Start, Seconds)
end.
Jump to Line
Something went wrong with that request. Please try again.