mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-03-11 13:26:17 +00:00
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:
@@ -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)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user