Skip to content

Commit 7c76f61

Browse files
functions refactored to map_reduce (#423)
* map_reduce * Apply suggestions from code review --------- Co-authored-by: Vince Foley <[email protected]>
1 parent 6eae916 commit 7c76f61

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/new_relic/sampler/beam.ex

+5-3
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,12 @@ defmodule NewRelic.Sampler.Beam do
9696
end
9797

9898
defp delta(:util, previous, current) do
99-
{active, total} =
99+
{_, {active, total}} =
100100
Enum.zip(previous, current)
101-
|> Enum.map(fn {{n, a0, t0}, {n, a1, t1}} -> {n, a1 - a0, t1 - t0} end)
102-
|> Enum.reduce({0, 0}, fn {_n, d_a, d_t}, {acc_a, acc_t} -> {acc_a + d_a, acc_t + d_t} end)
101+
|> Enum.map_reduce({0, 0}, fn
102+
{{n, a0, t0}, {n, a1, t1}}, {acc_a, acc_t} ->
103+
{{n, a1 - a0, t1 - t0}, {acc_a + (a1 - a0), acc_t + (t1 - t0)}}
104+
end)
103105

104106
safe_div(active, total)
105107
end

0 commit comments

Comments
 (0)