MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / parse_all

Method parse_all

src/executor/memory/tunables.rs:166–184  ·  view source on GitHub ↗

Parses `/proc/swaps`, whose rows read as `Filename Type Size Used Priority`.

(content: &str)

Source from the content-addressed store, hash-verified

164impl SwapArea {
165 /// Parses `/proc/swaps`, whose rows read as `Filename Type Size Used Priority`.
166 fn parse_all(content: &str) -> Vec<Self> {
167 content
168 .lines()
169 .skip(1)
170 .filter_map(|line| {
171 let mut columns = line.split_whitespace();
172 let path = columns.next()?.to_string();
173 // Type and Size sit between Filename and Used.
174 let used_kib = columns.nth(2)?.parse().ok()?;
175 let priority = columns.next()?.parse().ok()?;
176
177 Some(Self {
178 path,
179 used_kib,
180 priority,
181 })
182 })
183 .collect()
184 }
185
186 /// `swapon` arguments re-enabling the area with the priority it had.
187 /// `SWAP_FLAG_PREFER` only encodes `0..=32767`, so a kernel-assigned

Callers

nothing calls this directly

Calls 2

nextMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected