Suggestions for logging RAM high-water mark while benchmarking

Awesome, thank you! Is the snippet below kind of the right idea for how to use it?

defmodule TestErlangMemSup do

  def long_running_function() do
    File.read!("/my_huge_json_file.json")
    |> Jason.decode!()
  end

  def start_and_monitor(interval \\ 1000) do
    pid = spawn(fn -> long_running_function() end)
    log_and_repeat(pid, [], interval)
  end

  defp log_and_repeat(pid, log, interval) do
    if Process.alive?(pid) do
      log = [:memsup.get_system_memory_data() | log]
      :timer.sleep(interval)
      log_and_repeat(pid, log, interval)
    else
      log
    end
  end
end

(I’m just trying to run this interactively in a livebook for now). Maybe there’s a different way that people typically use :memsup, this is just my first crack at it :smile: