Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added BashoBench driver and config file in priv directory for perform…
…ance benchmarking
- Loading branch information
Vasco
committed
Oct 26, 2014
1 parent
515e980
commit ef88991
Showing
12 changed files
with
209 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,5 @@ etc/*.erl | |
out | ||
data | ||
data/* | ||
.rebar | ||
_rel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
-module(basho_bench_driver_rivus). | ||
-compile([{parse_transform, lager_transform}]). | ||
|
||
-export([new/1, run/4]). | ||
|
||
-include("basho_bench.hrl"). | ||
|
||
-record(state, { | ||
host, | ||
port, | ||
socket | ||
}). | ||
|
||
new(1) -> | ||
{Host, Port, Socket} = connect(), | ||
deploy_queries(Socket), | ||
|
||
{ok, #state{ | ||
host = Host, | ||
port = Port, | ||
socket = Socket}}; | ||
new(_Id) -> | ||
{Host, Port, Socket} = connect(), | ||
|
||
{ok, #state{ | ||
host = Host, | ||
port = Port, | ||
socket = Socket}}. | ||
|
||
connect() -> | ||
{Host, Port} = basho_bench_config:get(rivus_cep_tcp_serv, {"127.0.0.1", 5775}), | ||
{ok, Socket} = gen_tcp:connect(Host, Port, [{active, false}, {nodelay, true}, {packet, 4}, binary]), | ||
{Host, Port, Socket}. | ||
|
||
deploy_queries(Socket) -> | ||
Queries = basho_bench_config:get(rivus_cep_queries, []), | ||
lists:foreach(fun({Type, Query}) -> | ||
lager:info("Deploying query type: ~p, stmt: ~p", [Type, Query]), | ||
execute(Type, Query, Socket) end, Queries). | ||
|
||
execute(query, Query, Socket) -> | ||
ok = gen_tcp:send(Socket, term_to_binary({load_query, {Query, [benchmark_test], [], []}})); | ||
execute(event, Query, Socket) -> | ||
ok = gen_tcp:send(Socket, term_to_binary({load_query, {Query, [benchmark_event], [], []}})). | ||
|
||
send_event(Event, #state{socket = Socket} = State) -> | ||
case gen_tcp:send(Socket, term_to_binary({event, benchmark_test, Event})) of | ||
ok -> {ok, State}; | ||
Error -> Error | ||
end. | ||
|
||
create_event(_KeyGen, ValueGen) -> | ||
ValueGen. | ||
|
||
run(notify, KeyGen, ValueGen, State) -> | ||
Event = create_event(KeyGen, ValueGen), | ||
% Send message | ||
case send_event(Event, State) of | ||
{error, E} -> | ||
{error, E, State}; | ||
ok -> | ||
{ok, State}; | ||
{ok, State} -> {ok, State} | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{mode, {rate, 100000}}. | ||
|
||
{duration, 1}. | ||
|
||
{concurrent, 2}. | ||
|
||
{driver, basho_bench_driver_rivus}. | ||
|
||
{operations, [{notify, 1}]}. | ||
|
||
{key_generator, {uniform_int, 10000}}. | ||
{value_generator, {function, rivus_cep_event_gen, generate_event, [event11, 4]}}. | ||
|
||
{rivus_cep_queries,[{event, "define event11 as (attr1, attr2, attr3, attr4); "}, | ||
{query, "define correlation11 as | ||
select sum(ev1.attr1) | ||
from event11 as ev1 | ||
within 60 seconds; "}]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
-module(rivus_cep_event_gen). | ||
|
||
%% API | ||
-export([generate_event/3]). | ||
|
||
generate_event(_Id, EventName, ParamCount) when is_integer(ParamCount) andalso ParamCount>0 -> | ||
generate(ParamCount, [EventName]). | ||
|
||
generate(0, Acc) -> | ||
list_to_tuple(Acc); | ||
generate(ParamCount, Acc) -> | ||
generate(ParamCount-1, Acc ++ [random:uniform(1000)]). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{release, {rivus_cep, "0.1"}, | ||
[gproc, | ||
lager, | ||
folsom, | ||
gen_leader, | ||
rivus_cep]}. | ||
|
||
{extended_start_script, true}. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
lager | ||
]}, | ||
{mod, { rivus_cep_app, []}}, | ||
{env, []} | ||
{env, [{rivus_tcp_serv, {"127.0.0.1", 5775}}]} | ||
]}. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters