ultra parallelised download all in sticker vailidation performance Test

the issue is that the counter doesnt work, and that it does crash if the network request times out 😭
This commit is contained in:
neon443
2025-10-30 22:30:54 +00:00
parent dd02d5ca80
commit ff123811a0

View File

@@ -52,21 +52,35 @@ struct PerformanceTests {
@Test func MSStickerValidation() async throws { @Test func MSStickerValidation() async throws {
let downloadedEmojisBefore = hoarder.emojis.filter { $0.isLocal }.map { $0.id } let downloadedEmojisBefore = hoarder.emojis.filter { $0.isLocal }.map { $0.id }
await withDiscardingTaskGroup { group in
var i = 0 var i = 0
for emoji in hoarder.emojis { for emoji in hoarder.emojis {
i+=1 i+=1
let (data, _) = try! await URLSession.shared.data(from: emoji.remoteImageURL) group.addTask {
try! data.write(to: emoji.localImageURL) try? await Task.sleep(nanoseconds: 1)
async let (data, _) = try! URLSession.shared.data(from: emoji.remoteImageURL)
try! await data.write(to: emoji.localImageURL)
let _ = emoji.sticker?.validate() let _ = emoji.sticker?.validate()
emoji.deleteImage()
print("\(i)/\(hoarder.emojis.count) \(emoji.name)") print("\(i)/\(hoarder.emojis.count) \(emoji.name)")
} }
}
}
i = 0 // var i = 0
// for emoji in hoarder.emojis {
// i+=1
// async let (data, _) = try! URLSession.shared.data(from: emoji.remoteImageURL)
// try! await data.write(to: emoji.localImageURL)
// let _ = emoji.sticker?.validate()
// print("\(i)/\(hoarder.emojis.count) \(emoji.name)")
// }
var i = 0
for emoji in hoarder.emojis { for emoji in hoarder.emojis {
emoji.deleteImage()
guard downloadedEmojisBefore.contains(emoji.id) else { continue } guard downloadedEmojisBefore.contains(emoji.id) else { continue }
let (data, _) = try! await URLSession.shared.data(from: emoji.remoteImageURL) async let (data, _) = try! URLSession.shared.data(from: emoji.remoteImageURL)
try! data.write(to: emoji.localImageURL) try! await data.write(to: emoji.localImageURL)
print("\(i)/\(downloadedEmojisBefore) \(emoji.name)") print("\(i)/\(downloadedEmojisBefore) \(emoji.name)")
} }
} }