浏览代码

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.
pull/3/head
Markus Näsman 12 年前
提交者 Tuncer Ayaz
父节点
当前提交
2d139ea6c2
共有 1 个文件被更改,包括 14 次插入13 次删除
  1. +14
    -13
      src/rebar_eunit.erl

+ 14
- 13
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],

正在加载...
取消
保存