fix: Fix divison by zero in Performance Sample collector (#416)
* fix: Fix divison by zero in Performance Sample collector * use `isEmpty`
This commit is contained in:
parent
47266399cc
commit
f9dbb6921c
@ -236,6 +236,7 @@ extension CameraView: AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureAud
|
||||
private func evaluateNewPerformanceSamples() {
|
||||
lastFrameProcessorPerformanceEvaluation = DispatchTime.now()
|
||||
guard let videoDevice = videoDeviceInput?.device else { return }
|
||||
guard frameProcessorPerformanceDataCollector.hasEnoughData else { return }
|
||||
|
||||
let maxFrameProcessorFps = Double(videoDevice.activeVideoMinFrameDuration.timescale) * Double(videoDevice.activeVideoMinFrameDuration.value)
|
||||
let averageFps = 1.0 / frameProcessorPerformanceDataCollector.averageExecutionTimeSeconds
|
||||
|
@ -28,6 +28,10 @@ class FrameProcessorPerformanceDataCollector {
|
||||
private var counter = 0
|
||||
private var lastEvaluation = -1
|
||||
|
||||
var hasEnoughData: Bool {
|
||||
return !performanceSamples.isEmpty
|
||||
}
|
||||
|
||||
var averageExecutionTimeSeconds: Double {
|
||||
let sum = performanceSamples.reduce(0, +)
|
||||
let average = sum / Double(performanceSamples.count)
|
||||
|
Loading…
Reference in New Issue
Block a user