     // For rendering
     lazy var commandQueue:MTLCommandQueue = self.context.device.makeCommandQueue()
     lazy var renderer:VSRenderer = VSRenderer(device:self.context.device, pixelFormat:self.context.pixelFormat)
+
+    deinit {
+        print("frames = ", totalFrames, skippedFrames, Double(skippedFrames) / Double(totalFrames))
+    }
     
     override func viewDidLoad() {
         super.viewDidLoad()


extension SampleViewController3 : VSCaptureSessionDelegate {
    func didCaptureOutput(session:VSCaptureSession, texture textureIn:MTLTexture, sampleBuffer:CMSampleBuffer, presentationTime:CMTime) {
        if self.context.textureOut != nil {
            // The writer is behind. Skip this frame.
            return
        }
        self.context.set(texture: textureIn, sampleBuffer: sampleBuffer)

        }
    }
    var startTime:CMTime?
    var totalFrames = 0
    var skippedFrames = 0
    
    let context = VSContext(device: MTLCreateSystemDefaultDevice()!)
    var runtime:VSRuntime?
