标签:
1. timer模块中有函数tc(), 用于度量函数执行所消耗的时间, tc/1, tc/2的相关源码如下:
tc(F) -> Before = os:timestamp(), Val = F(), After = os:timestamp(), {now_diff(After, Before), Val}.
tc(F, A) ->
Before = os:timestamp(),
Val = apply(F, A),
After = os:timestamp(),
{now_diff(After, Before), Val}.
now_diff({A2, B2, C2}, {A1, B1, C1}) ->
((A2-A1)*1000000 + B2-B1)*1000000 + C2-C1.
标签:
原文地址:http://www.cnblogs.com/kamfon/p/5257610.html