> Erlang中文手册 > statistics/3 允许或禁止收集统计数据

sys:statistics/3

允许或禁止收集统计数据

用法:

statistics(Name, Flag, Timeout) -> ok | {ok, Statistics}

允许或禁止收集统计数据,参数 Timeout 表示该操作的超时时间。

参数 Flag 的取值有:

  • true:允许收集统计
  • get:获取收集的统计信息
  • false:禁止收集统计
RegisteredList = erlang:registered(),
RegisteredListLen = length(RegisteredList),
ranDOM:seed(erlang:now()),
Rand = random:uniform(RegisteredListLen),
RegisterName = lists:nth(Rand, RegisteredList),
sys:statistics(RegisterName, true, 5000).
RegisteredList = erlang:registered(),
RegisteredListLen = length(RegisteredList),
random:seed(erlang:now()),
Rand = random:uniform(RegisteredListLen),
RegisterName = lists:nth(Rand, RegisteredList),
sys:statistics(RegisterName, get, 5000).
RegisteredList = erlang:registered(),
RegisteredListLen = length(RegisteredList),
random:seed(erlang:now()),
Rand = random:uniform(RegisteredListLen),
RegisterName = lists:nth(Rand, RegisteredList),
sys:statistics(RegisterName, false, 5000).