Raxol.Utils.MemoryFormatter (Raxol v2.0.1)

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(1048576)
"1.00 MB"

iex> Raxol.Utils.MemoryFormatter.format_memory(1073741824)
"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"