Add basho_bench script/driver

This commit is contained in:
Kresten Krab Thorup 2012-01-05 22:28:39 +08:00 committed by Erik Søe Sørensen
parent 3118bd8c62
commit e09e2b2aa2
3 changed files with 103 additions and 1 deletions

View file

@ -3,5 +3,6 @@
{deps, [ {deps, [
{plain_fsm, "1.1.*", {git, "git://github.com/uwiger/plain_fsm", {branch, "master"}}}, {plain_fsm, "1.1.*", {git, "git://github.com/uwiger/plain_fsm", {branch, "master"}}},
{ebloom, "1.0.*", {git, "git://github.com/basho/ebloom.git", {branch, "master"}}} {ebloom, "1.0.*", {git, "git://github.com/basho/ebloom.git", {branch, "master"}}},
{basho_bench, ".*", {git, "git://github.com/basho/basho_bench.git", {branch, "master"}}}
]}. ]}.

View file

@ -0,0 +1,75 @@
-module(basho_bench_driver_fractal_btree).
-record(state, { tree,
filename,
flags,
sync_interval,
last_sync }).
-export([new/1,
run/4]).
-include_lib("basho_bench/include/basho_bench.hrl").
%% ====================================================================
%% API
%% ====================================================================
new(_Id) ->
%% Make sure bitcask is available
case code:which(fractal_btree) of
non_existing ->
?FAIL_MSG("~s requires fractal_btree to be available on code path.\n",
[?MODULE]);
_ ->
ok
end,
%% Get the target directory
Dir = basho_bench_config:get(fractal_btree_dir, "."),
Filename = filename:join(Dir, "test.frac"),
%% Look for sync interval config
case basho_bench_config:get(fractal_btree_sync_interval, infinity) of
Value when is_integer(Value) ->
SyncInterval = Value;
infinity ->
SyncInterval = infinity
end,
%% Get any bitcask flags
case fractal_btree:open(Filename) of
{error, Reason} ->
?FAIL_MSG("Failed to open fractal btree in ~s: ~p\n", [Filename, Reason]);
{ok, FBTree} ->
{ok, #state { tree = FBTree,
filename = Filename,
sync_interval = SyncInterval,
last_sync = os:timestamp() }}
end.
run(get, KeyGen, _ValueGen, State) ->
case fractal_btree:lookup(State#state.tree, KeyGen()) of
{ok, _Value} ->
{ok, State};
notfound ->
{ok, State};
{error, Reason} ->
{error, Reason}
end;
run(put, KeyGen, ValueGen, State) ->
case fractal_btree:put(State#state.tree, KeyGen(), ValueGen()) of
ok ->
{ok, State};
{error, Reason} ->
{error, Reason}
end;
run(delete, KeyGen, _ValueGen, State) ->
case fractal_btree:delete(State#state.tree, KeyGen()) of
ok ->
{ok, State};
{error, Reason} ->
{error, Reason}
end.

View file

@ -0,0 +1,26 @@
{mode, max}.
{duration, 1}.
{concurrent, 1}.
{driver, basho_bench_driver_fractal_btree}.
{key_generator, {int_to_bin,{uniform_int, 5000000}}}.
{value_generator, {fixed_bin, 10000}}.
{operations, [{get, 1}, {put, 1}]}.
%% the second element in the list below (e.g., "../../public/bitcask") must point to
%% the relevant directory of a fractal_btree installation
{code_paths, ["deps/stats",
"/Users/krab/Projects/fractal_btree/ebin",
"/Users/krab/Projects/fractal_btree/deps/plain_fsm/ebin",
"/Users/krab/Projects/fractal_btree/deps/ebloom/ebin"
]}.
{bitcask_dir, "/tmp/fractal_btree.bench"}.
{bitcask_flags, [o_sync]}.