Skip to content

Commit bf459b7

Browse files
author
Li Wen
authored
Merge pull request #41 from cloudant/fdb-acceptance-48-improve-perf
Imporve perf.git stack
2 parents 7e54aee + 15a7818 commit bf459b7

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

src/basho_bench.app.src

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@
8484
%%
8585
%% Value generators
8686
%%
87-
%% {fixed_bin, N} - Fixed size binary blob of N bytes
87+
%% Default value generator is random an integer
8888
%%
89-
{value_generator, {fixed_bin, 100}},
89+
{value_generator, {uniform_int, 1}},
9090

9191
{shutdown_timeout, 30000},
9292

src/basho_bench.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ run_benchmark(Configs) ->
9696
basho_bench_sup:start_child(),
9797
ok = basho_bench_stats:run(),
9898
ok = basho_bench_measurement:run(),
99-
ok = basho_bench_worker:run(basho_bench_worker_sup:workers()),
10099
ok = basho_bench_duration:run(),
100+
ok = basho_bench_worker:run(basho_bench_worker_sup:workers()),
101101
application:set_env(basho_bench_app, is_running, true).
102102

103103

src/basho_bench_duration.erl

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ handle_cast({worker_stopping, WorkerPid}, State) ->
7474
[] ->
7575
?INFO("The application has stopped early!", []),
7676
{stop, {shutdown, normal}, State};
77-
_ ->
77+
_ ->
7878
maybe_end({noreply, State})
7979
end;
8080

@@ -94,6 +94,12 @@ handle_info(Msg, State) ->
9494

9595

9696
terminate(Reason, #state{duration=DurationMins}) ->
97+
case Reason of
98+
{shutdown, normal} ->
99+
?CONSOLE("Test completed after ~p mins.\n", [DurationMins]);
100+
{shutdown, Reason} ->
101+
?CONSOLE("Test stopped: ~p\n", [Reason])
102+
end,
97103
case whereis(basho_bench_worker_sup) of
98104
undefined ->
99105
ok;
@@ -108,13 +114,8 @@ terminate(Reason, #state{duration=DurationMins}) ->
108114
run_hook(basho_bench_config:get(post_hook, no_op)),
109115
basho_bench_profiler:maybe_terminate_profiler(basho_bench_config:get(enable_profiler, false)),
110116
supervisor:terminate_child(basho_bench_sup, basho_bench_run_sup),
111-
case Reason of
112-
{shutdown, normal} ->
113-
?CONSOLE("Test completed after ~p mins.\n", [DurationMins]);
114-
{shutdown, Reason} ->
115-
?CONSOLE("Test stopped: ~p\n", [Reason])
116-
end,
117117
application:set_env(basho_bench_app, is_running, false),
118+
application:stop(basho_bench),
118119
ok.
119120

120121

@@ -134,16 +135,20 @@ maybe_end(Return) ->
134135
infinity ->
135136
Return;
136137
Duration ->
137-
case timer:now_diff(os:timestamp(), Start) of
138-
Elapsed when Elapsed / 60000000 >= Duration ->
139-
?CONSOLE("Stopping: ~p", [Elapsed]),
140-
{stop, normal, State};
141-
Elapsed ->
142-
Timeout = round(Duration*60000 - Elapsed/1000),
143-
case tuple_size(Return) of
144-
2 -> {Reply, State, Timeout};
145-
3 -> {Reply, Message, State, Timeout}
146-
end
138+
if Start /= undefined ->
139+
case timer:now_diff(os:timestamp(), Start) of
140+
Elapsed when Elapsed / 60000000 >= Duration ->
141+
?CONSOLE("Stopping: ~p", [Elapsed]),
142+
{stop, normal, State};
143+
Elapsed ->
144+
Timeout = round(Duration*60000 - Elapsed/1000),
145+
case tuple_size(Return) of
146+
2 -> {Reply, State, Timeout};
147+
3 -> {Reply, Message, State, Timeout}
148+
end
149+
end;
150+
true ->
151+
{Reply, State}
147152
end
148153
end.
149154

0 commit comments

Comments
 (0)