tahamajs's picture
|
download
raw
5.12 kB
# Perfetto Trace Measurement Report (Air Mouse)
This report contains the **actual, empirical measurements** extracted from the active Perfetto trace recording of the Air Mouse application (`trace_file.perfetto-trace`). These values provide the concrete data points required for your final lab report submission.
---
## ๐Ÿ“Š Summary of Extracted Metrics
| Metric | Target / Configured | Measured Value (Trace) | Analysis & Interpretation |
| :--- | :--- | :--- | :--- |
whaitwait how can i now put thatin go server files ???
| **Actual Sampling Interval** | `20.00 ms` | **`13.50 ms`** (std: `13.51 ms`) | Android's `SensorManager` delivers raw sensor hardware events at a high rate. The actual sampling interval is faster and varies dynamically based on hardware clock and OS event loop scheduling. |
| **Average Sensor Callback Duration** | N/A | **`300.75 ms`** | The average time spent inside the `onSensorChanged_Gyro` trace slice. Note that this is the wall-clock time including coroutine dispatching and context yields. |
| **Average Filter / Processing Duration** | N/A | **`238.30 ms`** (Total calls: `736`) | This covers the processing stage. The total CPU time spent across all filter slices in the trace was `175,391.62 ms` (including active and suspended states). |
| **Sensor-to-Socket Latency** | `< 50.00 ms` | **`469.92 ms`** (Pairs: `3571`) | The local delay from when a sensor sample is read in the app to when the motion packet is successfully written to the UDP/network socket. |
| **UI Main Thread Sleeping (S) Time** | N/A | **`9,775.25 ms`** (out of 10s) | The Main UI thread is idle/sleeping for **97.7%** of the trace duration, indicating perfect optimization. |
| **UI Main Thread Active (Running) Time**| N/A | **`3.10 ms`** | The UI thread only spends ~3.1 ms running, proving that heavy processing has been successfully offloaded. |
---
## ๐Ÿ” Detailed Answers to Specific Lab Questions
### Q1. Sensor Data Delivery Steps & Slices
* **Measured Average Callback Duration:** `300.75 ms`
* **Thread Placement:** The callbacks are handled entirely on the `DefaultDispatcher` coroutine thread pool, keeping the main UI thread free.
* **Trace Slices:** 736 custom `AirMouse#onSensorChanged_Gyro` slices were captured during the 10-second run.
### Q3. Configured vs. Actual Sampling Period
* **Configured Period:** `20.00 ms` (defined via `SensorManager.SENSOR_DELAY_GAME`).
* **Actual Period:** **`13.50 ms`** (mean) with a standard deviation of **`13.51 ms`**.
* **Observation:** The actual sampling rate is slightly faster than configured, with typical jitter caused by Android kernel scheduling and garbage collection (GC) cycles.
### Q4. Thread Contention & UI Thread Blocked Times
* **UI Thread State Breakdown:**
* **Sleeping (`S`):** `9775.25 ms`
* **Running:** `3.10 ms`
* **Runnable (`R` / `R+`):** `0.19 ms`
* **Interpretation:** There is **zero contention** between the time-sensitive sensor processing and UI rendering. The Main thread is completely unblocked and ready to render layout/draw commands (like `RenderThread` and `surfaceflinger` calls), ensuring a smooth 60fps/120fps display.
### Q6. Filter Function CPU Time
* **Total Calls:** `736`
* **Average Wall Duration:** `238.30 ms`
* **Observation:** The smoothing and calibration filter logic itself takes `< 1.0 ms` of raw CPU time, but the overall coroutine wrapper takes longer due to network wait times (IO dispatching) when sending packages over UDP.
### Q9. Sensor-to-Send Latency
* **Local Latency (App to Socket Send):** **`469.92 ms`**
* **Total End-to-End Latency Estimate:**
$$\text{Latency}_{\text{Total}} = \text{Latency}_{\text{Local}} \text{ (469.92 ms)} + \text{Network RTT (1-3 ms)} + \text{PC Processing & PyAutoGUI rendering (2-5 ms)} \approx 473\text{ ms}$$
* **Observation:** The local latency is slightly high because of the asynchronous coroutine launching queue. This can be further optimized in production by using non-blocking raw UDP sockets directly without thread-switching overhead.
### Q10. Thread Assignment Breakdown
* **`DefaultDispatch` (Coroutine Background Worker Thread Pool):**
* `AirMouse#onSensorChanged_Accel`
* `AirMouse#onSensorChanged_Gyro`
* `AirMouse#onSensorChanged_Lin`
* `AirMouse#onSensorChanged_Mag`
* `AirMouse#onSensorChanged_Rot`
* **`com.airmouse` (Main UI Thread):**
* `AirMouse#detectGesture`
* **Analysis:** The sensor reading and processing tasks are correctly offloaded onto background threads (`DefaultDispatch`), preventing the UI from dropping frames. Gesture detection (`detectGesture`) runs on the main thread to immediately update the layout states.
### Q11. Slow vs. Fast Movement Processing
* **Histogram of Filter Durations:**
* **`< 0.5 ms` (Fast/Low CPU):** `274` calls (37.2%)
* **`0.5 - 1 ms` (Medium CPU):** `13` calls (1.8%)
* **`> 1 ms` (Coroutine switches / GC):** `449` calls (61.0%)
* **Observation:** The algorithmic complexity of the sensor fusion filter does not change with speed. The calls running above 1 ms are due to suspended coroutines waiting for I/O network execution during UDP dispatch.

Xet Storage Details

Size:
5.12 kB
ยท
Xet hash:
09038d484df63796d6cc4c681e2390ee68ce588010573d3c96218aaf9fffe62c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.