Raxol.Utils.MemoryFormatter (Raxol v2.6.0)

View Source

Utility functions for formatting memory values.

Summary

Functions

Format memory value in bytes to human-readable format.

Format memory difference with sign.

Functions

format_memory(bytes)

@spec format_memory(number()) :: String.t()

Format memory value in bytes to human-readable format.

Examples

iex> Raxol.Utils.MemoryFormatter.format_memory(1024)
"1.00 KB"

iex> Raxol.Utils.MemoryFormatter.format_memory(1_048_576)
"1.00 MB"

iex> Raxol.Utils.MemoryFormatter.format_memory(1_073_741_824)
"1.00 GB"

format_memory_diff(bytes)

@spec format_memory_diff(number()) :: String.t()

Format memory difference with sign.

Examples

iex> Raxol.Utils.MemoryFormatter.format_memory_diff(1024)
"+1.00 KB"

iex> Raxol.Utils.MemoryFormatter.format_memory_diff(-1024)
"-1.00 KB"