Generate cachegrind file if erlgrind is available

This commit is contained in:
Tuncer Ayaz 2014-12-04 23:33:45 +01:00
parent 01ef314951
commit 39ab4e13fb
2 changed files with 26 additions and 3 deletions

View file

@ -37,7 +37,7 @@ files() ->
run(_Dir) ->
Cmd = "./rebar list-deps",
FprofFiles = ["fprof.trace", "fprof.analysis"],
FprofFiles = fprof_files(),
EflameFiles = ["eflame.trace", "eflame.svg"],
%% run a simple command (list-deps) without profiling
@ -81,6 +81,18 @@ run(_Dir) ->
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,
ExpectedFiles, UnexpectedFiles) ->
case {retest:sh(Cmd), FailureMode} of

View file

@ -165,8 +165,19 @@ profile(Config, Commands, fprof) ->
after
ok = fprof:profile(),
ok = fprof:analyse([{dest, "fprof.analysis"}]),
?CONSOLE("See fprof.analysis (generated from fprof.trace)~n", []),
ok
case rebar_utils:find_executable("erlgrind") of
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;
profile(Config, Commands, eflame) ->
case code:lib_dir(eflame) of