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

sys:statistics/2

允许或禁止收集统计数据

用法:

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

允许或禁止收集统计数据。

参数 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).
RegisteredList = erlang:registered(),
RegisteredListLen = length(RegisteredList),
random:seed(erlang:now()),
Rand = random:uniform(RegisteredListLen),
RegisterName = lists:nth(Rand, RegisteredList),
sys:statistics(RegisterName, get).
RegisteredList = erlang:registered(),
RegisteredListLen = length(RegisteredList),
random:seed(erlang:now()),
Rand = random:uniform(RegisteredListLen),
RegisterName = lists:nth(Rand, RegisteredList),
sys:statistics(RegisterName, false).