Skip to content

Commit

Permalink
Add bench target
Browse files Browse the repository at this point in the history
  • Loading branch information
lpgauth committed Jun 2, 2016
1 parent 96ef3c9 commit 2b4a488
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 17 deletions.
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ REBAR3=./bin/rebar3

all: compile

bench:
@echo "Benchmarking..."
@$(REBAR3) as test compile
@erl -noshell \
-pa _build/test/lib/*/ebin \
-eval 'shackle_bench:run()' \
-eval 'init:stop()'

clean:
@echo "Running rebar3 clean..."
@$(REBAR3) clean -a
Expand Down Expand Up @@ -37,8 +45,8 @@ profile:
@$(REBAR3) as test compile
@erl -noshell \
-pa _build/test/lib/*/ebin \
-eval 'shackle_profile:fprofx()' \
-eval 'init:stop()'
-eval 'shackle_profile:run()' \
-eval 'init:stop()'
@_build/test/lib/fprofx/erlgrindx -p fprofx.analysis
@$(CACHEGRIND) fprofx.cgrind

Expand All @@ -50,4 +58,4 @@ xref:
@echo "Running rebar3 xref..."
@$(REBAR3) xref

.PHONY: clean compile coveralls dialyzer edoc elvis eunit profile xref
.PHONY: bench clean compile coveralls dialyzer edoc elvis eunit profile xref
11 changes: 4 additions & 7 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
{platform_define, "19", 'RAND'}
]}.

{plugins, [
{coveralls,
{git, "https://github.com/markusn/coveralls-erl", {branch, "master"}}}
]}.

{profiles, [
{compile, [
{erl_opts, [
Expand All @@ -44,8 +39,10 @@
]},
{test, [
{deps, [
{fprofx, {git, "https://github.com/ransomr/fprofx.git",
{branch, "master"}}}
{fprofx,
{git, "https://github.com/ransomr/fprofx.git", {branch, "otp_19"}}},
{timing,
{git, "https://github.com/lpgauth/timing.git", {branch, "master"}}}
]},
{plugins, [
{coveralls,
Expand Down
28 changes: 28 additions & 0 deletions test/shackle_bench.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-module(shackle_bench).
-include("test.hrl").

-export([
run/0
]).

-define(N, 1000).
-define(P, 20).

%% public
-spec run() -> ok.

run() ->
shackle_test_utils:preload_modules(),
application:start(shackle),
arithmetic_tcp_client:start(),

Timing = timing:function(fun () ->
arithmetic_tcp_client:add(10, 10)
end, ?N, ?P),

io:format("~p~n", [Timing]),

arithmetic_tcp_client:stop(),
application:stop(shackle),

ok.
11 changes: 4 additions & 7 deletions test/shackle_profile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
-include("test.hrl").

-export([
fprofx/0
run/0
]).

-define(N, 1000).
-define(P, 20).

%% public
-spec fprofx() -> ok.

fprofx() ->
Filenames = filelib:wildcard("_build/default/lib/*/ebin/*.beam"),
Rootnames = [filename:rootname(Filename, ".beam") || Filename <- Filenames],
lists:foreach(fun code:load_abs/1, Rootnames),
-spec run() -> ok.

run() ->
shackle_test_utils:preload_modules(),
application:start(shackle),

fprofx:start(),
Expand Down
11 changes: 11 additions & 0 deletions test/shackle_test_utils.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-module(shackle_test_utils).

-export([
preload_modules/0
]).

%% public
preload_modules() ->
Filenames = filelib:wildcard("_build/default/lib/*/ebin/*.beam"),
Rootnames = [filename:rootname(Filename, ".beam") || Filename <- Filenames],
lists:foreach(fun code:load_abs/1, Rootnames).

0 comments on commit 2b4a488

Please sign in to comment.