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

Function parse_walltime_unwinding

src/cli/shared.rs:286–304  ·  view source on GitHub ↗

Parses `fp`, `dwarf`, or `dwarf, `.

(value: &str)

Source from the content-addressed store, hash-verified

284
285/// Parses `fp`, `dwarf`, or `dwarf,<bytes>`.
286fn parse_walltime_unwinding(value: &str) -> Result<WalltimeUnwinding, String> {
287 let (mode, stack_size) = match value.split_once(',') {
288 Some((mode, size)) => {
289 let size = size
290 .parse()
291 .map_err(|e| format!("Invalid stack size `{size}`: {e}"))?;
292 (mode, Some(size))
293 }
294 None => (value, None),
295 };
296 match (mode, stack_size) {
297 (DWARF_UNWINDING, stack_size) => Ok(WalltimeUnwinding::Dwarf { stack_size }),
298 (FRAME_POINTER_UNWINDING, None) => Ok(WalltimeUnwinding::FramePointer),
299 (FRAME_POINTER_UNWINDING, Some(_)) => {
300 Err("A stack size only applies to `dwarf` unwinding".into())
301 }
302 _ => Err("Expected `fp`, `dwarf`, or `dwarf,<bytes>`".into()),
303 }
304}

Callers

nothing calls this directly

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected