diff options
author | Markus Näsman <markus@botten.org> | 2012-08-28 13:46:54 +0200 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-08-30 17:27:43 +0200 |
commit | 2d139ea6c255aea6d98475ea72be12b1f29de545 (patch) | |
tree | 48a153555561419c12cadc5c5f940f4160df3953 /src | |
parent | ff8337f9b0256f3eb85179969b7577ab540714c1 (diff) |
Stop cover server between eunit runs for speed
Cover gets slower and slower for each application. This is due to the
cover_server internal state. Stopping the cover server between
eunit+cover runs, emptying the cover_server state, gives a ~5-6x speed
improvement when analyzing many Erlang modules. Stopping the cover
server replaces the earlier practice of doing a cover:reset before each
run. On a project consisting of 62 dependencies with a total of 1866
Erlang modules the running time of rebar eunit decreased from ~20
minutes to ~3 minutes.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_eunit.erl | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl index 432f5a2..532a584 100644 --- a/src/rebar_eunit.erl +++ b/src/rebar_eunit.erl @@ -140,6 +140,10 @@ run_eunit(Config, CodePath, SrcErls) -> ok end, + %% Stop cover to clean the cover_server state. This is important if we want + %% eunit+cover to not slow down when analyzing many Erlang modules. + ok = cover:stop(), + case EunitResult of ok -> ok; @@ -418,16 +422,16 @@ cover_init(false, _BeamFiles) -> {ok, not_enabled}; cover_init(true, BeamFiles) -> %% Attempt to start the cover server, then set its group leader to - %% ?EUNIT_DIR/cover.log, so all cover log messages will go there instead of - %% to stdout. If the cover server is already started we'll reuse that - %% pid. - {ok, CoverPid} = case cover:start() of - {ok, _P} = OkStart -> - OkStart; - {error,{already_started, P}} -> - {ok, P}; - {error, _Reason} = ErrorStart -> - ErrorStart + %% .eunit/cover.log, so all cover log messages will go there instead of + %% to stdout. If the cover server is already started, we'll kill that + %% server and start a new one in order not to inherit a polluted + %% cover_server state. + {ok, CoverPid} = case whereis(cover_server) of + undefined -> + cover:start(); + _ -> + cover:stop(), + cover:start() end, {ok, F} = OkOpen = file:open( @@ -436,9 +440,6 @@ cover_init(true, BeamFiles) -> group_leader(F, CoverPid), - %% Make sure any previous runs of cover don't unduly influence - cover:reset(), - ?INFO("Cover compiling ~s\n", [rebar_utils:get_cwd()]), Compiled = [{Beam, cover:compile_beam(Beam)} || Beam <- BeamFiles], |