Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module (config_bench).
- -export ([doit/2]).
- doit(Conns, Reps) ->
- doit(Conns, Reps, false).
- doit(Conns, Reps, AlsoWrite) ->
- Conf = couch_config:all(),
- Begin = erlang:now(),
- Self = self(),
- Writer = if AlsoWrite -> spawn(fun write_stuff/0); true -> Self end,
- [spawn(fun() -> grab(Self, Conf, Reps) end) || _I <- lists:seq(1,Conns)],
- ok = wait_result(Conns),
- Writer ! stop,
- % 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.
- write_stuff() ->
- receive stop -> ok
- after 0 ->
- couch_config:set("some_block", "foo",
- binary_to_list(couch_uuids:new())),
- write_stuff()
- end.
- % lookup all config values
- grab(Parent, _Conf, 0) ->
- Parent ! done;
- grab(Parent, Conf, M) ->
- {Keys, _Values} = lists:unzip(Conf),
- [couch_config:get(K,V) || {K,V} <- Keys],
- grab(Parent, Conf, M-1).
Add Comment
Please, Sign In to add comment