Skip to content

Commit 5acd5a6

Browse files
committed
feat(operations): Display average speed in performance graph
Change the performance graph marker to show average speed instead of current speed from the last sample, providing a better overall view of transfer performance. Changes: - Calculate average speed across all samples using arithmetic mean - Update string resource to workspace_operation_performance_avg_speed_label - More accurately represents overall operation performance This aligns with user expectations for performance metrics where average throughput is more meaningful than instantaneous final speed.
1 parent 51d70c4 commit 5acd5a6

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

app-workspace/src/main/java/eu/darken/butler/workspace/ui/operations/details/OperationPerformanceGraph.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,16 @@ fun OperationPerformanceGraph(
210210
),
211211
)
212212

213-
// Current speed label at last data point (Windows Explorer style)
214-
val lastSample = performanceHistory.samples.lastOrNull()
215-
if (lastSample != null) {
216-
val currentSpeed = formatSpeed(lastSample.bytesPerSecond)
213+
// Average speed label (Windows Explorer style)
214+
if (performanceHistory.samples.isNotEmpty()) {
215+
val averageSpeed = performanceHistory.samples
216+
.map { it.bytesPerSecond }
217+
.average()
218+
.toLong()
219+
val formattedSpeed = formatSpeed(averageSpeed)
217220

218221
Text(
219-
text = stringResource(R.string.workspace_operation_performance_speed_label, currentSpeed),
222+
text = stringResource(R.string.workspace_operation_performance_avg_speed_label, formattedSpeed),
220223
style = MaterialTheme.typography.labelMedium,
221224
color = MaterialTheme.colorScheme.onSurface,
222225
modifier = Modifier

app-workspace/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,5 @@
142142

143143
<!-- Performance Graph -->
144144
<string name="workspace_operation_performance_not_enough_data">Not enough data</string>
145-
<string name="workspace_operation_performance_speed_label">Speed: %1$s</string>
145+
<string name="workspace_operation_performance_avg_speed_label">Speed Ø: %1$s</string>
146146
</resources>

0 commit comments

Comments
 (0)