Skip to content

Commit

Permalink
Align runtime memory usage formatting with LiveDashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Aug 19, 2024
1 parent 765bb42 commit 1ac585c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/livebook/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,10 @@ defmodule Livebook.Utils do
"1.2 MB"
iex> Livebook.Utils.format_bytes(1_363_148_800)
"1.4 GB"
"1.3 GB"
iex> Livebook.Utils.format_bytes(1_503_238_553_600)
"1.5 TB"
"1.4 TB"
"""
@spec format_bytes(non_neg_integer()) :: String.t()
Expand All @@ -675,10 +675,10 @@ defmodule Livebook.Utils do
"#{:erlang.float_to_binary(value, decimals: 1)} #{unit}"
end

defp memory_unit(:TB), do: 1_000_000_000_000
defp memory_unit(:GB), do: 1_000_000_000
defp memory_unit(:MB), do: 1_000_000
defp memory_unit(:KB), do: 1_000
defp memory_unit(:TB), do: 1024 * 1024 * 1024 * 1024
defp memory_unit(:GB), do: 1024 * 1024 * 1024
defp memory_unit(:MB), do: 1024 * 1024
defp memory_unit(:KB), do: 1024

@doc """
Converts the given IP address into a valid hostname.
Expand Down

0 comments on commit 1ac585c

Please sign in to comment.