Skip to content

Commit

Permalink
Add basho bench driver for pipeline queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavisp3 committed Oct 21, 2011
1 parent 52addf9 commit c79f8fe
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 3 deletions.
2 changes: 1 addition & 1 deletion priv/basho_bench_eredis.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{driver, basho_bench_driver_eredis}.

{code_paths, ["/home/knutin/git/eredis/ebin/"]}.
{code_paths, ["../eredis/ebin"]}.

{operations, [{get,1}, {put,4}]}.

Expand Down
17 changes: 17 additions & 0 deletions priv/basho_bench_eredis_pipeline.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{mode, max}.
%{mode, {rate, 5}}.

{duration, 15}.

{concurrent, 30}.

{driver, basho_bench_driver_eredis}.

{code_paths, ["../eredis/ebin"]}.

{operations, [{pipeline_get,100}, {pipeline_put,1}]}.

{key_generator, {uniform_int, 10000}}.

{value_generator, {function, basho_bench_driver_eredis, value_gen, []}}.
%{value_generator, {fixed_bin, 1}}.
4 changes: 2 additions & 2 deletions priv/basho_bench_erldis.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

{driver, basho_bench_driver_erldis}.

{code_paths, ["/home/knutin/git/eredis/ebin/",
"/home/knutin/git/erldis/ebin/"]}.
{code_paths, ["../eredis/ebin",
"../erldis/ebin/"]}.

{operations, [{get,1}, {put,4}]}.

Expand Down
41 changes: 41 additions & 0 deletions src/basho_bench_driver_eredis.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ run(get, KeyGen, _ValueGen, Client) ->
{error, timeout, Client}
end;

run(pipeline_get, KeyGen, _ValueGen, Client) ->
Seq = lists:seq(1, 5),
P = [["GET", KeyGen()] || _ <- Seq],

case catch(eredis:qp(Client, P, 500)) of
{error, Reason} ->
{error, Reason, Client};
{'EXIT', {timeout, _}} ->
{error, timeout, Client};
Res ->
case check_pipeline_get(Res, Seq) of
ok ->
{ok, Client};
{error, Reason} ->
{error, Reason, Client}
end
end;

run(put, KeyGen, ValueGen, Client) ->
case catch(eredis:q(Client, ["SET", KeyGen(), ValueGen()], 100)) of
{ok, <<"OK">>} ->
Expand All @@ -39,8 +57,31 @@ run(put, KeyGen, ValueGen, Client) ->
{error, Reason, Client};
{'EXIT', {timeout, _}} ->
{error, timeout, Client}
end;

run(pipeline_put, KeyGen, ValueGen, Client) ->
Seq = lists:seq(1, 5),
P = [["SET", KeyGen(), ValueGen()] || _ <- Seq],
R = [{ok, <<"OK">>} || _ <- Seq],

case catch(eredis:qp(Client, P, 500)) of
R ->
{ok, Client};
{error, Reason} ->
{error, Reason, Client};
{'EXIT', {timeout, _}} ->
{error, timeout, Client}
end.


check_pipeline_get([], []) ->
ok;
check_pipeline_get([{ok, _}|Res], [_|Seq]) ->
check_pipeline_get(Res, Seq);
check_pipeline_get([{error, Reason}], _) ->
{error, Reason}.


value_gen(_Id) ->
fun() ->
%% %% Example data from http://json.org/example.html
Expand Down

0 comments on commit c79f8fe

Please sign in to comment.