diff options
Diffstat (limited to 'crates/ra_ide_api/src/status.rs')
-rw-r--r-- | crates/ra_ide_api/src/status.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index 0dde30ae0..686ab97d2 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs | |||
@@ -30,11 +30,12 @@ pub(crate) fn status(db: &RootDatabase) -> String { | |||
30 | interner.len() | 30 | interner.len() |
31 | }; | 31 | }; |
32 | format!( | 32 | format!( |
33 | "{}\n{}\n{}\nn_defs {}\nGC {:?} seconds ago", | 33 | "{}\n{}\n{}\nn_defs {}\n\njemalloc: {}\nGC {:?} seconds ago", |
34 | files_stats, | 34 | files_stats, |
35 | symbols_stats, | 35 | symbols_stats, |
36 | syntax_tree_stats, | 36 | syntax_tree_stats, |
37 | n_defs, | 37 | n_defs, |
38 | MemoryStats::current(), | ||
38 | db.last_gc.elapsed().as_secs(), | 39 | db.last_gc.elapsed().as_secs(), |
39 | ) | 40 | ) |
40 | } | 41 | } |
@@ -126,6 +127,31 @@ impl FromIterator<TableEntry<SourceRootId, Arc<SymbolIndex>>> for LibrarySymbols | |||
126 | } | 127 | } |
127 | } | 128 | } |
128 | 129 | ||
130 | struct MemoryStats { | ||
131 | allocated: Bytes, | ||
132 | resident: Bytes, | ||
133 | } | ||
134 | |||
135 | impl MemoryStats { | ||
136 | fn current() -> MemoryStats { | ||
137 | jemalloc_ctl::epoch().unwrap(); | ||
138 | MemoryStats { | ||
139 | allocated: Bytes(jemalloc_ctl::stats::allocated().unwrap()), | ||
140 | resident: Bytes(jemalloc_ctl::stats::resident().unwrap()), | ||
141 | } | ||
142 | } | ||
143 | } | ||
144 | |||
145 | impl fmt::Display for MemoryStats { | ||
146 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | ||
147 | write!( | ||
148 | fmt, | ||
149 | "{} allocated {} resident", | ||
150 | self.allocated, self.resident, | ||
151 | ) | ||
152 | } | ||
153 | } | ||
154 | |||
129 | #[derive(Default)] | 155 | #[derive(Default)] |
130 | struct Bytes(usize); | 156 | struct Bytes(usize); |
131 | 157 | ||