Skip to content

Commit

Permalink
Merge pull request #100 from nathanaschbacher/nathan_dev
Browse files Browse the repository at this point in the history
summary.r changes, PB Search testing, and ETS testing.
  • Loading branch information
nathanaschbacher committed Sep 13, 2013
2 parents 0174992 + 351b680 commit ee276ff
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/basho_bench_ets.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{mode, max}.

{duration, 3}.

{concurrent, 4}.

{driver, basho_bench_driver_ets}.

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

{key_generator, {int_to_bin_littleendian, {uniform_int, 1000}}}.

{value_generator, {fixed_bin, 100000}}.

24 changes: 24 additions & 0 deletions examples/riakc_pb.search.devrel.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{mode, max}.

{duration, 10}.

{concurrent, 3}.

{driver, basho_bench_driver_riakc_pb}.

%%{key_generator, {int_to_bin, {uniform_int, 10000}}}.
%%{value_generator, {fixed_bin, 10000}}.

{riakc_pb_ips, [
{{127,0,0,1}, 10017}, %% {Ip, Port}
{{127,0,0,1}, 10027}, %% {Ip, Port}
{{127,0,0,1}, [10037, 10047]} %% {Ip, Ports}
]}.

{riakc_pb_search_queries, [{<<"index">>, "query", [{rows,10}]}]}. %% last element of the tuple is a list of Search options/params.

{operations, [{search, 1}]}.

%% {query_step_interval, 60}. %% time in seconds to run each query before switching to the next one in the list, default is 60 seconds.
%% {operations, [{search_interval, 1}]}.

5 changes: 5 additions & 0 deletions priv/summary.r
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ latency_plot <- ggplot(b$latencies, aes(x = elapsed)) +

# Plot 99 and 99.9th percentiles
plot2 <- latency_plot +
geom_point(aes(y = X99th, color = "X99th")) +
geom_point(aes(y = X99_9th, color = "X99_9th")) +
geom_smooth(aes(y = X99th, color = "X99th")) +
geom_smooth(aes(y = X99_9th, color = "X99_9th")) +
scale_color_hue("Percentile",
Expand All @@ -70,6 +72,9 @@ plot2 <- latency_plot +

# Plot median, mean and 95th percentiles
plot3 <- latency_plot +
geom_point(aes(y = median, color = "median")) +
geom_point(aes(y = mean, color = "mean")) +
geom_point(aes(y = X95th, color = "X95th")) +
geom_smooth(aes(y = median, color = "median")) +
geom_smooth(aes(y = mean, color = "mean")) +
geom_smooth(aes(y = X95th, color = "X95th")) +
Expand Down
30 changes: 30 additions & 0 deletions src/basho_bench_driver_ets.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-module(basho_bench_driver_ets).

-export([new/1,
run/4]).

new(_Id) ->
EtsTable = ets:new(basho_bench, [ordered_set]),
{ok, EtsTable}.

run(get, KeyGen, _ValueGen, EtsTable) ->
Start = KeyGen(),
case ets:lookup(EtsTable, Start) of
[] ->
{ok, EtsTable};
[{_Key, _Val}] ->
{ok, EtsTable};
Error ->
{error, Error, EtsTable}
end;

run(put, KeyGen, ValueGen, EtsTable) ->
Object = {KeyGen(), ValueGen()},
ets:insert(EtsTable, Object),
{ok, EtsTable};

run(delete, KeyGen, _ValueGen, EtsTable) ->
Start = KeyGen(),
ets:delete(EtsTable, Start),
{ok, EtsTable}.

39 changes: 39 additions & 0 deletions src/basho_bench_driver_riakc_pb.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
dw,
pw,
rw,
search_queries,
query_step_interval,
start_time,
keylist_length,
preloaded_keys,
timeout_general,
Expand Down Expand Up @@ -79,6 +82,8 @@ new(Id) ->
RW = basho_bench_config:get(riakc_pb_rw, Replies),
PW = basho_bench_config:get(riakc_pb_pw, Replies),
PR = basho_bench_config:get(riakc_pb_pr, Replies),
SearchQs = basho_bench_config:get(riakc_pb_search_queries, []),
SearchQStepIval = basho_bench_config:get(query_step_interval, 60),
Bucket = basho_bench_config:get(riakc_pb_bucket, <<"test">>),
KeylistLength = basho_bench_config:get(riakc_pb_keylist_length, 1000),
PreloadedKeys = basho_bench_config:get(
Expand All @@ -99,6 +104,9 @@ new(Id) ->
dw = DW,
rw = RW,
pw = PW,
search_queries = SearchQs,
query_step_interval = SearchQStepIval,
start_time = erlang:now(),
keylist_length = KeylistLength,
preloaded_keys = PreloadedKeys,
timeout_general = get_timeout_general(),
Expand Down Expand Up @@ -230,6 +238,34 @@ run(listkeys, _KeyGen, _ValueGen, State) ->
{error, Reason} ->
{error, Reason, State}
end;
run(search, _KeyGen, _ValueGen, #state{search_queries=SearchQs}=State) ->
[{Index, Query, Options}|_] = SearchQs,

NewState = State#state{search_queries=roll_list(SearchQs)},

case riakc_pb_socket:search(NewState#state.pid, Index, Query, Options, NewState#state.timeout_read) of
{ok, _Results} ->
{ok, NewState};
{error, Reason} ->
{error, Reason, NewState}
end;
run(search_interval, _KeyGen, _ValueGen, #state{search_queries=SearchQs, start_time=StartTime, query_step_interval=Interval}=State) ->
[{Index, Query, Options}|_] = SearchQs,

Now = erlang:now(),
case timer:now_diff(Now, StartTime) of
_MicroSec when _MicroSec > (Interval * 1000000) ->
NewState = State#state{search_queries=roll_list(SearchQs),start_time=Now};
_MicroSec ->
NewState = State
end,

case riakc_pb_socket:search(NewState#state.pid, Index, Query, Options, NewState#state.timeout_read) of
{ok, _Results} ->
{ok, NewState};
{error, Reason} ->
{error, Reason, NewState}
end;
run(mr_bucket_erlang, _KeyGen, _ValueGen, State) ->
mapred(State, State#state.bucket, ?ERLANG_MR);
run(mr_bucket_js, _KeyGen, _ValueGen, State) ->
Expand Down Expand Up @@ -336,6 +372,9 @@ make_keylist(Bucket, KeyGen, Count) ->
[{Bucket, list_to_binary(KeyGen())}
|make_keylist(Bucket, KeyGen, Count-1)].

roll_list(List) ->
[lists:last(List) | lists:sublist(List, length(List) - 1)].

mapred_valgen(_Id, MaxRand) ->
fun() ->
list_to_binary(integer_to_list(random:uniform(MaxRand)))
Expand Down

0 comments on commit ee276ff

Please sign in to comment.