-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
888 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Copyright (c) SRG SSR. All rights reserved. | ||
// | ||
// License information is available from the LICENSE file. | ||
// | ||
|
||
import Charts | ||
import PillarboxPlayer | ||
import SwiftUI | ||
|
||
struct DataVolumeChart: View { | ||
let metrics: [Metrics] | ||
let limit: Int | ||
|
||
var body: some View { | ||
chart() | ||
summary() | ||
} | ||
|
||
private var bytesTransferred: String { | ||
ByteCountFormatStyle().format(metrics.last?.total.numberOfBytesTransferred ?? 0) | ||
} | ||
|
||
@ViewBuilder | ||
private func chart() -> some View { | ||
Chart(Array(metrics.suffix(limit).enumerated()), id: \.offset) { metrics in | ||
BarMark( | ||
x: .value("Index", metrics.offset), | ||
y: .value("Data volume (MB)", metrics.element.increment.numberOfBytesTransferred / 1_000_000), | ||
width: .inset(1) | ||
) | ||
.foregroundStyle(.cyan) | ||
} | ||
.chartXAxis(.hidden) | ||
.chartXScale(domain: 0...limit - 1) | ||
.chartYAxisLabel("MB") | ||
.padding(.vertical) | ||
} | ||
|
||
@ViewBuilder | ||
private func summary() -> some View { | ||
Text("Total \(bytesTransferred)") | ||
.font(.caption2) | ||
.foregroundStyle(.secondary) | ||
.frame(maxWidth: .infinity, alignment: .center) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Copyright (c) SRG SSR. All rights reserved. | ||
// | ||
// License information is available from the LICENSE file. | ||
// | ||
|
||
import Charts | ||
import PillarboxPlayer | ||
import SwiftUI | ||
|
||
struct FrameDropsChart: View { | ||
let metrics: [Metrics] | ||
let limit: Int | ||
|
||
var body: some View { | ||
chart() | ||
summary() | ||
} | ||
|
||
private var total: Int { | ||
metrics.last?.total.numberOfDroppedVideoFrames ?? 0 | ||
} | ||
|
||
@ViewBuilder | ||
private func chart() -> some View { | ||
Chart(Array(metrics.suffix(limit).enumerated()), id: \.offset) { metrics in | ||
BarMark( | ||
x: .value("Index", metrics.offset), | ||
y: .value("Frame drops", metrics.element.increment.numberOfDroppedVideoFrames), | ||
width: .inset(1) | ||
) | ||
.foregroundStyle(.purple) | ||
} | ||
.chartXAxis(.hidden) | ||
.chartXScale(domain: 0...limit - 1) | ||
.padding(.vertical) | ||
} | ||
|
||
@ViewBuilder | ||
private func summary() -> some View { | ||
Text("Total \(total)") | ||
.font(.caption2) | ||
.foregroundStyle(.secondary) | ||
.frame(maxWidth: .infinity, alignment: .center) | ||
} | ||
} |
Oops, something went wrong.