mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 11:09:55 +00:00
Merge pull request #405 from tuncer/erlgrind
Generate cachegrind file if erlgrind is available
This commit is contained in:
commit
49a96a6318
2 changed files with 26 additions and 3 deletions
|
@ -37,7 +37,7 @@ files() ->
|
||||||
|
|
||||||
run(_Dir) ->
|
run(_Dir) ->
|
||||||
Cmd = "./rebar list-deps",
|
Cmd = "./rebar list-deps",
|
||||||
FprofFiles = ["fprof.trace", "fprof.analysis"],
|
FprofFiles = fprof_files(),
|
||||||
EflameFiles = ["eflame.trace", "eflame.svg"],
|
EflameFiles = ["eflame.trace", "eflame.svg"],
|
||||||
|
|
||||||
%% run a simple command (list-deps) without profiling
|
%% run a simple command (list-deps) without profiling
|
||||||
|
@ -81,6 +81,18 @@ run(_Dir) ->
|
||||||
|
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
fprof_files() ->
|
||||||
|
FprofFiles = ["fprof.trace", "fprof.analysis"],
|
||||||
|
CgrindFiles = ["fprof.cgrind"],
|
||||||
|
case os:find_executable("erlgrind") of
|
||||||
|
false ->
|
||||||
|
retest:log(info,
|
||||||
|
"erlgrind escript not found. skip fprof.cgrind check~n"),
|
||||||
|
FprofFiles;
|
||||||
|
_ErlGrind ->
|
||||||
|
FprofFiles ++ CgrindFiles
|
||||||
|
end.
|
||||||
|
|
||||||
check(Cmd, FailureMode, ExpectedOutput, UnexpectedOutput,
|
check(Cmd, FailureMode, ExpectedOutput, UnexpectedOutput,
|
||||||
ExpectedFiles, UnexpectedFiles) ->
|
ExpectedFiles, UnexpectedFiles) ->
|
||||||
case {retest:sh(Cmd), FailureMode} of
|
case {retest:sh(Cmd), FailureMode} of
|
||||||
|
|
|
@ -165,8 +165,19 @@ profile(Config, Commands, fprof) ->
|
||||||
after
|
after
|
||||||
ok = fprof:profile(),
|
ok = fprof:profile(),
|
||||||
ok = fprof:analyse([{dest, "fprof.analysis"}]),
|
ok = fprof:analyse([{dest, "fprof.analysis"}]),
|
||||||
?CONSOLE("See fprof.analysis (generated from fprof.trace)~n", []),
|
case rebar_utils:find_executable("erlgrind") of
|
||||||
ok
|
false ->
|
||||||
|
?CONSOLE(
|
||||||
|
"See fprof.analysis (generated from fprof.trace)~n", []),
|
||||||
|
ok;
|
||||||
|
ErlGrind ->
|
||||||
|
Cmd = ?FMT("~s fprof.analysis fprof.cgrind", [ErlGrind]),
|
||||||
|
{ok, []} = rebar_utils:sh(Cmd, [{use_stdout, false},
|
||||||
|
abort_on_error]),
|
||||||
|
?CONSOLE("See fprof.analysis (generated from fprof.trace)"
|
||||||
|
" and fprof.cgrind~n", []),
|
||||||
|
ok
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
profile(Config, Commands, eflame) ->
|
profile(Config, Commands, eflame) ->
|
||||||
case code:lib_dir(eflame) of
|
case code:lib_dir(eflame) of
|
||||||
|
|
Loading…
Reference in a new issue