xprof
xprof copied to clipboard
Return-value matching
Allow to filter functions based on their return value (instead of arguments).
Apart from the XProf-flavoured match-spec takes an additional parameter
RetMatchFun
which matches the value returned by the function. The call latency
is only measured if there is a match.
RetMatchFun
receives the value returned by the traced function as a single
argument and can return:
-
false
: no match, don't measure -
true
: match, measure and capture the original return value. -
{true, NewValue}
: match, measure and captureNewValue
instead of the original return value.
If RetMatchFun
is arity-2 it could match on an exception (class and reason). Should an arity-1 RetMatchFun
match on exceptions of form {Class, Reason}
too?
We can think of some shortcuts eg. as a convenience function_clause
could mean no match (don't have to handle all return values, only the positive case, as in the second example below)
Query example (suggestion):
#retmatch matchfun: fun(List) -> lists:member(12, List) end, mfa: ...
#retmatch matchfun: fun(error, badarg) -> true end, mfa: ...
It would be useful if the graph would show both a total count (number of return_trace messages) and matched count (only when matchfun matches) to see a rate how oftern thr return value matches.