Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functions refactored to map_reduce #423

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/new_relic/sampler/beam.ex
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ defmodule NewRelic.Sampler.Beam do
defp delta(:util, previous, current) do
{active, total} =
binaryseed marked this conversation as resolved.
Show resolved Hide resolved
Enum.zip(previous, current)
|> Enum.map(fn {{n, a0, t0}, {n, a1, t1}} -> {n, a1 - a0, t1 - t0} end)
|> Enum.reduce({0, 0}, fn {_n, d_a, d_t}, {acc_a, acc_t} -> {acc_a + d_a, acc_t + d_t} end)
|> Enum.map_reduce({0, 0}, fn
{{n, a0, t0}, {n, a1, t1}}, {acc_a, acc_t} ->
{{n, a1 - a0, t1 - t0}, {acc_a + (a1 - a0), acc_t + (t1 - t0)}}
end)
|> elem(1)
binaryseed marked this conversation as resolved.
Show resolved Hide resolved

safe_div(active, total)
end
Expand Down