Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. # call this before the code under inspection
  2. defp clock_start(x) do
  3. now = :erlang.timestamp()
  4. Process.put(:"$clock_start", now)
  5. Process.put(:"$clock_step_start", now)
  6. Process.put(:"$clock_steps", [])
  7.  
  8. x
  9. end
  10.  
  11. # call this after start when you want to checkpoint intermediate steps
  12. defp cLOCK_STEP(x, tag) do
  13. now = :erlang.timestamp()
  14.  
  15. step_start = Process.get(:"$clock_step_start")
  16. steps = Process.get(:"$clock_steps", [])
  17. Process.put(:"$clock_steps", [{tag, :timer.now_diff(now, step_start)} | steps])
  18. Process.put(:"$clock_step_start", now)
  19.  
  20. x
  21. end
  22.  
  23. # call this to get all accumulated measured steps
  24. defp clock_read(), do: Process.get(:"$clock_steps") |> Enum.reverse()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement