Parse the `profile` argument to either the `run` or `serve` commands.
(s: &str)
| 505 | impl 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)] |