Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # call this before the code under inspection
- defp clock_start(x) do
- now = :erlang.timestamp()
- Process.put(:"$clock_start", now)
- Process.put(:"$clock_step_start", now)
- Process.put(:"$clock_steps", [])
- x
- end
- # call this after start when you want to checkpoint intermediate steps
- defp cLOCK_STEP(x, tag) do
- now = :erlang.timestamp()
- step_start = Process.get(:"$clock_step_start")
- steps = Process.get(:"$clock_steps", [])
- Process.put(:"$clock_steps", [{tag, :timer.now_diff(now, step_start)} | steps])
- Process.put(:"$clock_step_start", now)
- x
- end
- # call this to get all accumulated measured steps
- defp clock_read(), do: Process.get(:"$clock_steps") |> Enum.reverse()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement