this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add unit to monotonic_time

garrison fbd43f8b 8f2d2e28

+12 -5
+12 -5
lib/trinity/sim_system.ex
··· 6 6 defp get_sim, do: Process.get(simulation_key()) 7 7 8 8 @spec monotonic_time :: integer 9 - def monotonic_time do 9 + def monotonic_time(unit \\ :native) do 10 10 case get_sim() do 11 - nil -> System.monotonic_time() 12 - _sim -> sim_monotonic_time() 11 + nil -> System.monotonic_time(unit) 12 + _sim -> sim_monotonic_time(unit) 13 13 end 14 14 end 15 15 16 - defp sim_monotonic_time do 16 + defp sim_monotonic_time(unit) do 17 17 %{now: now} = get_sim() 18 - :atomics.get(now, 1) 18 + 19 + time = :atomics.get(now, 1) 20 + case unit do 21 + :native -> time 22 + :millisecond -> time 23 + :microsecond -> time * 1000 24 + _ -> raise ArgumentError, "Unsupported unit #{inspect(unit)}" 25 + end 19 26 end 20 27 end