Current section
Files
Jump to
Current section
Files
lib/nop/element/statistics.ex
defmodule NOP.Element.Statistics do
defmacro __using__([]) do
quote do
defp get_statistics_from_state(state) do
Map.get(state, :statistics)
end
defp add_statistics_to_state(state, count) do
old = get_statistics_from_state(state)
Map.put(state, :statistics, old + count)
end
defp reset_statistics_to_state(state) do
Map.put(state, :statistics, 0)
end
defp get_timestamp() do
:erlang.system_time(:millisecond)
end
def diff_between_timestamp(beg_time, end_time) do
end_time - beg_time
end
def handle_call(:get_statistics, _from, state) do
{:reply, get_statistics_from_state(state), state}
end
def handle_cast(:reset_statistics, state) do
{:noreply, reset_statistics_to_state(state)}
end
end
end
end