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.

29 rivejä
1.1 KiB

5 vuotta sitten
5 vuotta sitten
2 vuotta sitten
5 vuotta sitten
4 vuotta sitten
5 vuotta sitten
4 vuotta sitten
5 vuotta sitten
4 vuotta sitten
4 vuotta sitten
  1. %% 三目元算符
  2. -define(CASE(Cond, Then, That), case Cond of true -> Then; _ -> That end).
  3. -define(CASE(Expr, Expect, Then, ExprRet, That), case Expr of Expect -> Then; ExprRet -> That end).
  4. %% IF-DO表达式
  5. -define(IF(IFTure, DoThat), (IFTure) andalso (DoThat)).
  6. %%汉字unicode编码范围 0x4e00 - 0x9fa5
  7. -define(UNICODE_CHINESE_BEGIN, (4 * 16 * 16 * 16 + 14 * 16 * 16)).
  8. -define(UNICODE_CHINESE_END, (9 * 16 * 16 * 16 + 15 * 16 * 16 + 10 * 16 + 5)).
  9. -define(PRINT(Format, Args),
  10. io:format(Format, Args)).
  11. %% format_record(record名, record数据) -> [{#record.field, record_field_value}]
  12. -define(recordToKvList(RecordName, RecordData),
  13. fun() ->
  14. Fields = record_info(fields, RecordName),
  15. [_ | Data] = tuple_to_list(RecordData),
  16. {RecordName, lists:zip(Fields, Data)}
  17. end()).
  18. -define(pdMemInfo, '$pdMemInfo').
  19. %% 运行时内存初始化宏
  20. -define(MII(), utVMInfo:memInfoInit(?MODULE, ?LINE)).
  21. %% 运行时内存默认打印函数
  22. -define(MIP(), utVMInfo:memInfoPrint(?MODULE, ?LINE, 100)).
  23. %% 运行时内存带阀值参数打印函数
  24. -define(MIP(Threshold), utVMInfo:memInfoPrint(?MODULE, ?LINE, Threshold)).