Skip to content

Instantly share code, notes, and snippets.

@boorad
Created November 6, 2009 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boorad/228138 to your computer and use it in GitHub Desktop.
Save boorad/228138 to your computer and use it in GitHub Desktop.
% fprof:apply(M, F, A)
% fprof:profile()
% fprof:analyse()
-module (reads_bench).
-export ([doit/2]).
doit(Conns, Reps) ->
Begin = erlang:now(),
Self = self(),
[spawn(fun() -> read(Self, Reps) end) || _I <- lists:seq(1,Conns)],
ok = wait_result(Conns),
% seconds to run the test
timer:now_diff(erlang:now(), Begin)/1000000.
wait_result(0) ->
ok;
wait_result(N) ->
receive done -> wait_result(N-1) end.
read(Parent, 0) ->
Parent ! done;
read(Parent, M) ->
%% for showroom
% {ok, Db} = showroom_api:open_db(<<"test_suite_db">>, []),
% {ok, _} = showroom_api:open_doc(Db, <<"_local/foo">>),
% showroom_api:close_db(Db),
%% for couch
{ok, Db} = couch_db:open(<<"test_suite_db">>, []),
{ok, _} = couch_db:open_doc(Db, <<"_local/foo">>),
couch_db:close(Db),
read(Parent, M-1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment