MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / parse

Method parse

src/common.rs:507–528  ·  view source on GitHub ↗

Parse the `profile` argument to either the `run` or `serve` commands.

(s: &str)

Source from the content-addressed store, hash-verified

505impl Profile {
506 /// Parse the `profile` argument to either the `run` or `serve` commands.
507 pub fn parse(s: &str) -> Result<Profile> {
508 let parts = s.split(',').collect::<Vec<_>>();
509 match &parts[..] {
510 ["perfmap"] => Ok(Profile::Native(wasmtime::ProfilingStrategy::PerfMap)),
511 ["jitdump"] => Ok(Profile::Native(wasmtime::ProfilingStrategy::JitDump)),
512 ["vtune"] => Ok(Profile::Native(wasmtime::ProfilingStrategy::VTune)),
513 ["pulley"] => Ok(Profile::Native(wasmtime::ProfilingStrategy::Pulley)),
514 ["guest"] => Ok(Profile::Guest {
515 path: "wasmtime-guest-profile.json".to_string(),
516 interval: Duration::from_millis(10),
517 }),
518 ["guest", path] => Ok(Profile::Guest {
519 path: path.to_string(),
520 interval: Duration::from_millis(10),
521 }),
522 ["guest", path, dur] => Ok(Profile::Guest {
523 path: path.to_string(),
524 interval: WasmtimeOptionValue::parse(Some(dur))?,
525 }),
526 _ => bail!("unknown profiling strategy: {s}"),
527 }
528 }
529}
530
531#[derive(Copy, Clone, Debug)]

Callers

nothing calls this directly

Calls 4

OkFunction · 0.85
splitMethod · 0.80
parseFunction · 0.50
to_stringMethod · 0.45

Tested by

no test coverage detected