Skip to content

Commit c4eba84

Browse files
gonzalobfzhongwencool
authored andcommitted
correct the units shown for memory data
The units returned by `to_byte/1` are kilobytes (KB), megabytes (MB) and gigabytes (GB) but the actual numeric value are for kibibyte (KiB), mebibyte(MiB) and gibibyte(GiB). This is because the division is by 1024. I found this problem when I was comparing the value agaist the output of rebar:info and didn't match. I did a similar patch a few years ago on OTP's observer [1]. [1] erlang/otp#6063
1 parent 12ef053 commit c4eba84

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/observer_cli_lib.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ to_byte(Byte) when is_integer(Byte), Byte < 1024 ->
8484
[erlang:integer_to_list(Byte), $\s, $B];
8585
%% kilobyte
8686
to_byte(Byte) when Byte < 1024 * 1024 ->
87-
[erlang:float_to_list(Byte / 1024, [{decimals, 4}]), $\s, $K, $B];
87+
[erlang:float_to_list(Byte / 1024, [{decimals, 4}]), $\s, $K, $i, $B];
8888
%% megabyte
8989
to_byte(Byte) when Byte < 1024 * 1024 * 1024 ->
90-
[erlang:float_to_list(Byte / (1024 * 1024), [{decimals, 4}]), $\s, $M, $B];
90+
[erlang:float_to_list(Byte / (1024 * 1024), [{decimals, 4}]), $\s, $M, $i, $B];
9191
%% megabyte
9292
to_byte(Byte) when is_integer(Byte) ->
93-
[erlang:float_to_list(Byte / (1024 * 1024 * 1024), [{decimals, 4}]), $\s, $G, $B];
93+
[erlang:float_to_list(Byte / (1024 * 1024 * 1024), [{decimals, 4}]), $\s, $G, $i, $B];
9494
%% process died
9595
to_byte(Byte) ->
9696
[to_list(Byte)].

0 commit comments

Comments
 (0)