MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / simulator_performance_payload

Function simulator_performance_payload

packages/server/src/api/routes.rs:1991–2024  ·  view source on GitHub ↗
(
    state: AppState,
    udid: String,
    pid: Option<i32>,
    window_ms: Option<u64>,
)

Source from the content-addressed store, hash-verified

1989}
1990
1991async fn simulator_performance_payload(
1992 state: AppState,
1993 udid: String,
1994 pid: Option<i32>,
1995 window_ms: Option<u64>,
1996) -> Result<Json<Value>, AppError> {
1997 if android::is_android_id(&udid) {
1998 return Err(AppError::bad_request(
1999 "Performance gauges are only supported for iOS simulators.",
2000 ));
2001 }
2002 let foreground = performance_foreground_process(&state, &udid).await;
2003 let display_signal = simulator_display_signal(state.clone(), &udid).await;
2004 let snapshot = state
2005 .performance
2006 .snapshot(
2007 &udid,
2008 PerformanceQuery {
2009 pid,
2010 history_window_ms: window_ms.unwrap_or(120_000).clamp(10_000, 10 * 60 * 1000),
2011 },
2012 foreground,
2013 display_signal,
2014 )
2015 .await?;
2016 let events = performance_log_events(&state, &udid, &snapshot).await;
2017 let mut value = serde_json::to_value(snapshot).map_err(|error| {
2018 AppError::internal(format!("Unable to encode performance data: {error}"))
2019 })?;
2020 if let Some(object) = value.as_object_mut() {
2021 object.insert("events".to_owned(), Value::Array(events));
2022 }
2023 Ok(json(value))
2024}
2025
2026async fn sample_process_stack(
2027 State(state): State<AppState>,

Callers 2

simulator_performanceFunction · 0.85

Calls 8

is_android_idFunction · 0.85
simulator_display_signalFunction · 0.85
performance_log_eventsFunction · 0.85
jsonFunction · 0.85
insertMethod · 0.80
cloneMethod · 0.65
snapshotMethod · 0.45

Tested by

no test coverage detected