From f40f63ca45817aee0737fcdf073ae29071ffe81e Mon Sep 17 00:00:00 2001 From: Peter <> Date: Wed, 3 Jul 2019 02:32:20 +0300 Subject: [PATCH] More stats --- .../TelegramUI/AnimatedStickerUtils.swift | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift b/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift index 8ef4d1e800..ecc5e3233f 100644 --- a/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift +++ b/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift @@ -193,11 +193,12 @@ func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: CGSize, let startTime = CACurrentMediaTime() var drawingTime: Double = 0 var appendingTime: Double = 0 + var deltaTime: Double = 0 + var compressionTime: Double = 0 let decompressedData = TGGUnzipData(data) if let decompressedData = decompressedData, let player = LottieInstance(data: decompressedData, cacheKey: cacheKey) { let endFrame = Int(player.frameCount) - print("read at \(CACurrentMediaTime() - startTime)") if cancelled.with({ $0 }) { return @@ -257,16 +258,15 @@ func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: CGSize, let drawStartTime = CACurrentMediaTime() memset(currentFrameData, 0, frameLength) player.renderFrame(with: Int32(currentFrame), into: currentFrameData.assumingMemoryBound(to: UInt8.self), width: Int32(size.width), height: Int32(size.height)) + drawingTime += CACurrentMediaTime() - drawStartTime let appendStartTime = CACurrentMediaTime() - //compressRGBAToBC1(currentFrameData.assumingMemoryBound(to: UInt8.self), Int32(size.width), Int32(size.height), yuvaFrameData.assumingMemoryBound(to: UInt8.self)) - encodeRGBAToYUVA(yuvaFrameData.assumingMemoryBound(to: UInt8.self), currentFrameData.assumingMemoryBound(to: UInt8.self), Int32(size.width), Int32(size.height)) - //decodeYUVAToRGBA(yuvaFrameData.assumingMemoryBound(to: UInt8.self), singleContext.bytes.assumingMemoryBound(to: UInt8.self), Int32(size.width), Int32(size.height)) appendingTime += CACurrentMediaTime() - appendStartTime + let deltaStartTime = CACurrentMediaTime() var lhs = previousYuvaFrameData.assumingMemoryBound(to: UInt64.self) var rhs = yuvaFrameData.assumingMemoryBound(to: UInt64.self) for _ in 0 ..< yuvaLength / 8 { @@ -274,9 +274,9 @@ func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: CGSize, lhs = lhs.advanced(by: 1) rhs = rhs.advanced(by: 1) } + deltaTime += CACurrentMediaTime() - deltaStartTime - drawingTime += CACurrentMediaTime() - drawStartTime - + let compressionStartTime = CACurrentMediaTime() compressedFrameData.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer) -> Void in let length = compression_encode_buffer(bytes, compressedFrameDataLength, previousYuvaFrameData.assumingMemoryBound(to: UInt8.self), yuvaLength, scratchData, COMPRESSION_LZFSE) var frameLengthValue: Int32 = Int32(length) @@ -288,6 +288,8 @@ func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: CGSize, previousYuvaFrameData = yuvaFrameData yuvaFrameData = tmp + compressionTime += CACurrentMediaTime() - compressionStartTime + currentFrame += 1 } @@ -296,6 +298,8 @@ func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: CGSize, print("animation render time \(CACurrentMediaTime() - startTime)") print("of which drawing time \(drawingTime)") print("of which appending time \(appendingTime)") + print("of which delta time \(deltaTime)") + print("of which compression time \(compressionTime)") } } return ActionDisposable {