erlang各种有用的函数包括一些有用nif封装,还有一些性能测试case。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
671 B

5 years ago
2 years ago
5 years ago
  1. -ifdef(OTP_RELEASE). %% this implies 21 or higher
  2. -define(EXCEPTION(Class, Reason, Stacktrace), Class:Reason:Stacktrace).
  3. -define(GET_STACK(Stacktrace), Stacktrace).
  4. -else.
  5. -define(EXCEPTION(Class, Reason, _), Class:Reason).
  6. -define(GET_STACK(_), erlang:get_stacktrace()).
  7. -endif.
  8. -define(GSS(Stacktrace), try throw(0) catch _:_:Stacktrace -> Stacktrace end).
  9. %% 追溯打印函数调用流程
  10. -define(PRINT_STACK(Tag),
  11. Stack =
  12. try
  13. throw(0)
  14. catch
  15. ?EXCEPTION(_Class, _Reason, Stacktrace) ->
  16. ?GET_STACK(Stacktrace)
  17. end,
  18. io:format("tarce tag:~p cur Stacktrace:", [Tag]),
  19. io:format(utParseStack:parseStack(Stack))
  20. ).