diff options
author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2014-12-04 23:33:45 +0100 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2014-12-08 23:09:20 +0100 |
commit | 39ab4e13fb848528d33c8dbcbf8cd01174ea871c (patch) | |
tree | 4c9269a3bc3d38762d7e976d242c8ea4e25ca494 | |
parent | 01ef3149518c44fc361be1d9a414c3768ad269dd (diff) | |
download | rebar-39ab4e13fb848528d33c8dbcbf8cd01174ea871c.tar.gz |
Generate cachegrind file if erlgrind is available
-rw-r--r-- | inttest/profile/profile_rt.erl | 14 | ||||
-rw-r--r-- | src/rebar.erl | 15 |
2 files changed, 26 insertions, 3 deletions
diff --git a/inttest/profile/profile_rt.erl b/inttest/profile/profile_rt.erl index 1b87768..b128517 100644 --- a/inttest/profile/profile_rt.erl +++ b/inttest/profile/profile_rt.erl @@ -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 diff --git a/src/rebar.erl b/src/rebar.erl index 52eb1e7..8f1e940 100644 --- a/src/rebar.erl +++ b/src/rebar.erl @@ -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 |