| | 1 | -module(beam_stats_ets_table). |
| | 2 | |
| | 3 | -include("include/beam_stats_ets_table.hrl"). |
| | 4 | |
| | 5 | -export_type( |
| | 6 | [ t/0 |
| | 7 | , id/0 |
| | 8 | ]). |
| | 9 | |
| | 10 | -export( |
| | 11 | [ of_id/1 |
| | 12 | ]). |
| | 13 | |
| | 14 | -type id() :: |
| | 15 | atom() |
| | 16 | | ets:tid() |
| | 17 | % integer() is just a workaround, to let us mock ets:tid(), which is |
| | 18 | % opaque, but represented as an integer, without Dialyzer complaining. |
| | 19 | | integer() |
| | 20 | . |
| | 21 | |
| | 22 | -type t() :: |
| | 23 | #?MODULE{}. |
| | 24 | |
| | 25 | -spec of_id(id()) -> |
| | 26 | t(). |
| | 27 | of_id(ID) -> |
| | 28 | WordSize = beam_stats_source:erlang_system_info(wordsize), |
| | 29 | NumberOfWords = beam_stats_source:ets_info(ID, memory), |
| | 30 | NumberOfBytes = NumberOfWords * WordSize, |
| | 31 | #?MODULE |
| | 32 | { id = ID |
| | 33 | , name = beam_stats_source:ets_info(ID, name) |
| | 34 | , size = beam_stats_source:ets_info(ID, size) |
| | 35 | , memory = NumberOfBytes |
| | 36 | }. |