Contents
- Measurements
- Observations
- Incremental reads + withUnsafeBytes is unequivocally the best method
- AsyncBytes (bytes(from:)) is surprisingly not bad – in this specific case
- withUnsafeBytes is way faster than “safe” access to Data‘s contents
- withUnsafeBytes doubles the memory usage of the target Data
- Reading a file with URLSession takes more than one CPU core
- for loops are faster than forEach & reduce
- forEach & reduce perform the same
- Similar performance characteristics between [old] Intel Xeons and Apple Silicon
- You’re probably not going to be I/O limited on Apple SSDs
What’s the best way to read a stream of bytes with URLSession
? That’s the simple question I set out to answer. I wrote some benchmarks. They read a 128 MiB file and perform a contrived aggregation of its content bytes (a joking “hash” of them, merely to ensure the actual reads aren’t optimised out).
β οΈ In a nutshell, the results here demonstrate the best-case performance for each of the methods evaluated. These benchmarks are very simple, which makes them relatively easy for the Swift compiler to optimise well. In less trivial, real-world code, the optimiser might not do so great. So these benchmarks and their results are merely one collective data point in the bigger picture of just how the heck to read files efficiently.
There’s two key decisions you must make: which specific URLSession
API will you use, and how will you access the bytes themselves.
Measurements
Each benchmark was run a hundred times or for 30 seconds (whichever limit was hit first). I’m highlighting here just the medians (in general there wasn’t much variation anyway), but you can dig into the other percentiles & metrics via the disclosure triangles, if you like.
I’m pretty sure the reads were all served out of the kernel’s in-memory file system cache, judging by the lack of SSD read I/O reported by iStat Menus. But I didn’t go out of my way to verify this.
β οΈ “Peak RAM” is as reported by the Benchmark package, based on (if I understand it correctly) periodic sampling of the process RSS. As such it’s not necessarily completely accurate, due to the potential to miss brief peaks.
M2 MacBook Air
Method | Wall time (ms) | CPU time (ms) | Throughput (MiB/s) | Peak RAM (MB) |
---|---|---|---|---|
bytes(from:) and for loop | 79 | 138 | 1,620 | 91 |
bytes(from:) and reduce | 79 | 138 | 1,620 | 84 |
data(from:) and for loop | 605 | 641 | 212 | 265 |
data(from:) and for loop inside withUnsafeBytes | 60 | 95 | 2,133 | 338 |
data(from:) and forEach | 765 | 800 | 167 | 262 |
data(from:) and reduce | 750 | 784 | 171 | 290 |
dataTask(with:) and an incremental delegate with for loop | 560 | 617 | 229 | 53 |
dataTask(with:) and an incremental delegate with for loop inside withUnsafeBytes | 36 | 75 | 3,556 | 26 |
dataTask(with:) and an incremental delegate with forEach | 719 | 775 | 178 | 51 |
dataTask(with:) and an incremental delegate with reduce | 709 | 765 | 167 | 45 |
dataTask(with:completionHandler:) and for loop | 590 | 630 | 217 | 442 |
dataTask(with:completionHandler:) and for loop inside withUnsafeBytes | 57 | 98 | 2,246 | 504 |
dataTask(with:completionHandler:) and forEach | 742 | 783 | 173 | 470 |
dataTask(with:completionHandler:) and reduce | 742 | 786 | 173 | 485 |
Full results (raw text)
bytewise read using bytes(from:) and for loop
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 35 β 36 β 37 β 37 β 37 β 67 β 69 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 68 β 91 β 91 β 91 β 94 β 94 β 94 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases β 1841 β 1869 β 1883 β 1911 β 1925 β 1939 β 1953 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains β 1312 β 1332 β 1342 β 1362 β 1372 β 1382 β 1392 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 24 β 25 β 25 β 25 β 25 β 25 β 25 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 136 β 137 β 138 β 138 β 138 β 139 β 140 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 79 β 79 β 79 β 79 β 80 β 81 β 81 β 100 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using bytes(from:) and reduce
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 35 β 36 β 37 β 37 β 37 β 67 β 69 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 68 β 83 β 84 β 85 β 88 β 88 β 88 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases β 1840 β 1869 β 1897 β 1911 β 1925 β 1953 β 1967 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains β 1312 β 1332 β 1352 β 1362 β 1372 β 1392 β 1402 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 24 β 25 β 25 β 25 β 25 β 25 β 25 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 137 β 138 β 138 β 138 β 138 β 139 β 140 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 79 β 79 β 79 β 79 β 80 β 80 β 81 β 100 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using data(from:) and for loop
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 40 β 43 β 44 β 45 β 47 β 76 β 76 β 50 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 167 β 230 β 265 β 278 β 286 β 297 β 297 β 50 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 50 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 50 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 21 β 23 β 23 β 23 β 23 β 23 β 23 β 50 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 631 β 639 β 641 β 647 β 659 β 676 β 676 β 50 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 600 β 603 β 605 β 610 β 625 β 642 β 642 β 50 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using data(from:) and for loop inside withUnsafeBytes
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 39 β 44 β 44 β 45 β 47 β 75 β 76 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 150 β 293 β 338 β 398 β 419 β 439 β 445 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases β 11 β 11 β 11 β 11 β 11 β 11 β 11 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains β 5 β 5 β 5 β 5 β 5 β 5 β 5 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 21 β 22 β 22 β 23 β 23 β 23 β 23 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 79 β 93 β 95 β 96 β 98 β 106 β 110 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 49 β 59 β 60 β 61 β 62 β 68 β 71 β 100 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using data(from:) and forEach
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 41 β 43 β 44 β 45 β 47 β 77 β 77 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 145 β 228 β 262 β 279 β 292 β 296 β 296 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 22 β 22 β 23 β 23 β 23 β 23 β 23 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 782 β 794 β 800 β 805 β 806 β 816 β 816 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 750 β 760 β 765 β 771 β 773 β 783 β 783 β 40 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using data(from:) and reduce
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 41 β 44 β 44 β 45 β 47 β 77 β 77 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 165 β 254 β 290 β 338 β 353 β 361 β 361 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 22 β 22 β 22 β 23 β 23 β 23 β 23 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 771 β 777 β 784 β 789 β 792 β 796 β 796 β 40 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 738 β 742 β 750 β 756 β 758 β 760 β 760 β 40 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:) and an incremental delegate with for loop
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 34 β 35 β 36 β 36 β 37 β 69 β 69 β 54 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 52 β 52 β 53 β 57 β 57 β 57 β 57 β 54 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 54 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 54 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 26 β 26 β 27 β 27 β 27 β 27 β 27 β 54 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 616 β 616 β 617 β 617 β 617 β 620 β 620 β 54 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 559 β 559 β 560 β 560 β 560 β 564 β 564 β 54 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:) and an incremental delegate with for loop inside withUnsafeBytes
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 47 β 51 β 53 β 55 β 57 β 87 β 87 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 22 β 26 β 26 β 27 β 27 β 27 β 27 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases β 6135 β 6147 β 6147 β 6147 β 6150 β 6150 β 6150 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains β 2046 β 2051 β 2051 β 2051 β 2051 β 2051 β 2051 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 35 β 35 β 35 β 35 β 35 β 35 β 35 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 73 β 74 β 75 β 75 β 76 β 76 β 76 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 35 β 36 β 36 β 36 β 36 β 37 β 37 β 100 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:) and an incremental delegate with forEach
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 34 β 35 β 36 β 36 β 37 β 68 β 68 β 42 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 47 β 50 β 51 β 51 β 51 β 51 β 51 β 42 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 42 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 42 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 26 β 27 β 27 β 27 β 27 β 27 β 27 β 42 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 773 β 774 β 775 β 775 β 776 β 779 β 779 β 42 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 717 β 718 β 719 β 719 β 719 β 722 β 722 β 42 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:) and an incremental delegate with reduce
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 34 β 35 β 36 β 36 β 37 β 70 β 70 β 43 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 45 β 45 β 45 β 45 β 45 β 45 β 45 β 43 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 43 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 43 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 26 β 26 β 27 β 27 β 27 β 27 β 27 β 43 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 763 β 764 β 765 β 766 β 766 β 768 β 768 β 43 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 707 β 709 β 709 β 710 β 710 β 714 β 714 β 43 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:completionHandler:) and for loop
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 39 β 43 β 44 β 47 β 50 β 79 β 79 β 51 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 378 β 410 β 442 β 471 β 496 β 528 β 528 β 51 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 51 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 51 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 27 β 27 β 28 β 28 β 28 β 28 β 28 β 51 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 624 β 627 β 630 β 632 β 634 β 640 β 640 β 51 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 587 β 589 β 590 β 594 β 597 β 601 β 601 β 51 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:completionHandler:) and for loop inside withUnsafeBytes
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 38 β 43 β 45 β 46 β 48 β 76 β 76 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 394 β 462 β 504 β 525 β 547 β 583 β 587 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases β 5 β 5 β 5 β 5 β 5 β 5 β 5 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains β 3 β 3 β 3 β 3 β 3 β 3 β 3 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 27 β 27 β 28 β 28 β 28 β 28 β 28 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 92 β 96 β 98 β 100 β 102 β 105 β 106 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 55 β 57 β 57 β 58 β 59 β 61 β 63 β 100 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:completionHandler:) and forEach
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 38 β 41 β 44 β 47 β 51 β 74 β 74 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 391 β 430 β 470 β 560 β 587 β 617 β 617 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 27 β 28 β 28 β 28 β 28 β 28 β 28 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 773 β 776 β 783 β 789 β 790 β 795 β 795 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 734 β 737 β 742 β 749 β 751 β 755 β 755 β 41 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:completionHandler:) and reduce
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 38 β 43 β 44 β 46 β 51 β 77 β 77 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 348 β 408 β 451 β 485 β 499 β 548 β 548 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 27 β 28 β 28 β 28 β 28 β 28 β 28 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 770 β 776 β 786 β 788 β 793 β 796 β 796 β 41 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 732 β 737 β 742 β 749 β 752 β 755 β 755 β 41 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
10-core iMac Pro
Method | Wall time (ms) | CPU time (ms) | Throughput (MiB/s) | Peak RAM (MB) |
---|---|---|---|---|
bytes(from:) and for loop | 138 | 250 | 928 | 54 |
bytes(from:) and reduce | 139 | 251 | 921 | 53 |
data(from:) and for loop | 953 | 1,023 | 134 | 257 |
data(from:) and for loop inside withUnsafeBytes | 140 | 208 | 914 | 344 |
data(from:) and forEach | 1,181 | 1,254 | 108 | 236 |
data(from:) and reduce | 1,163 | 1,233 | 110 | 232 |
dataTask(with:) and an incremental delegate with for loop | 848 | 964 | 151 | 40 |
dataTask(with:) and an incremental delegate with for loop inside withUnsafeBytes | 56 | 140 | 2,286 | 23 |
dataTask(with:) and an incremental delegate with forEach | 1,066 | 1,181 | 120 | 35 |
dataTask(with:) and an incremental delegate with reduce | 1,072 | 1,185 | 119 | 43 |
dataTask(with:completionHandler:) and for loop | 948 | 1,026 | 135 | 375 |
dataTask(with:completionHandler:) and for loop inside withUnsafeBytes | 137 | 215 | 934 | 591 |
dataTask(with:completionHandler:) and forEach | 1,179 | 1,258 | 109 | 370 |
dataTask(with:completionHandler:) and reduce | 1,176 | 1,254 | 109 | 416 |
Full results (raw text)
bytewise read using bytes(from:) and for loop
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 36 β 37 β 37 β 37 β 37 β 68 β 69 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 45 β 51 β 54 β 56 β 62 β 66 β 66 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases β 1952 β 2023 β 2051 β 2079 β 2093 β 2135 β 2135 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains β 1392 β 1442 β 1462 β 1482 β 1492 β 1522 β 1522 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 21 β 21 β 21 β 21 β 21 β 21 β 21 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 245 β 248 β 250 β 251 β 254 β 259 β 267 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 136 β 138 β 138 β 140 β 141 β 145 β 146 β 100 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using bytes(from:) and reduce
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 36 β 37 β 37 β 37 β 37 β 67 β 69 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 48 β 52 β 53 β 54 β 56 β 58 β 60 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases β 1953 β 2009 β 2037 β 2065 β 2079 β 2121 β 2121 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains β 1392 β 1432 β 1452 β 1472 β 1482 β 1512 β 1512 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 21 β 21 β 21 β 21 β 21 β 21 β 21 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 246 β 249 β 251 β 253 β 256 β 274 β 278 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 136 β 138 β 139 β 140 β 141 β 150 β 151 β 100 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using data(from:) and for loop
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 41 β 42 β 43 β 43 β 72 β 76 β 76 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 188 β 243 β 257 β 266 β 279 β 316 β 316 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 18 β 18 β 19 β 19 β 19 β 19 β 19 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 1010 β 1015 β 1023 β 1031 β 1040 β 1060 β 1060 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 941 β 946 β 953 β 958 β 968 β 985 β 985 β 32 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using data(from:) and for loop inside withUnsafeBytes
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 38 β 42 β 43 β 44 β 47 β 72 β 73 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 244 β 328 β 344 β 352 β 358 β 369 β 370 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases β 11 β 11 β 11 β 11 β 11 β 11 β 11 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains β 5 β 5 β 5 β 5 β 5 β 5 β 5 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 18 β 18 β 18 β 18 β 18 β 19 β 19 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 203 β 207 β 208 β 210 β 213 β 221 β 234 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 135 β 139 β 140 β 141 β 143 β 148 β 159 β 100 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using data(from:) and forEach
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 41 β 42 β 43 β 43 β 73 β 75 β 75 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 171 β 225 β 236 β 263 β 283 β 288 β 288 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 18 β 18 β 18 β 19 β 19 β 19 β 19 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 1247 β 1250 β 1254 β 1266 β 1271 β 1284 β 1284 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 1177 β 1179 β 1181 β 1194 β 1199 β 1211 β 1211 β 26 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using data(from:) and reduce
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 39 β 42 β 43 β 43 β 72 β 79 β 79 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 207 β 226 β 232 β 243 β 260 β 278 β 278 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 18 β 18 β 18 β 19 β 19 β 19 β 19 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 1225 β 1228 β 1233 β 1243 β 1250 β 1269 β 1269 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 1157 β 1160 β 1163 β 1172 β 1178 β 1198 β 1198 β 26 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:) and an incremental delegate with for loop
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 35 β 35 β 36 β 36 β 65 β 68 β 68 β 36 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 32 β 36 β 40 β 45 β 48 β 52 β 52 β 36 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 36 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 36 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 23 β 23 β 23 β 23 β 23 β 23 β 23 β 36 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 954 β 958 β 964 β 965 β 975 β 992 β 992 β 36 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 841 β 845 β 848 β 851 β 857 β 871 β 871 β 36 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:) and an incremental delegate with for loop inside withUnsafeBytes
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 47 β 51 β 53 β 54 β 56 β 83 β 84 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 17 β 20 β 23 β 24 β 25 β 25 β 25 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases β 5895 β 6067 β 6087 β 6099 β 6111 β 6123 β 6123 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains β 1966 β 2024 β 2031 β 2035 β 2039 β 2043 β 2043 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 32 β 32 β 32 β 32 β 33 β 33 β 33 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 137 β 139 β 140 β 142 β 147 β 152 β 155 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 55 β 55 β 56 β 56 β 58 β 60 β 62 β 100 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:) and an incremental delegate with forEach
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 35 β 35 β 36 β 36 β 65 β 69 β 69 β 29 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 29 β 33 β 35 β 37 β 39 β 41 β 41 β 29 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 29 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 29 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 23 β 23 β 23 β 23 β 23 β 23 β 23 β 29 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 1169 β 1179 β 1181 β 1184 β 1190 β 1205 β 1205 β 29 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 1056 β 1065 β 1066 β 1069 β 1074 β 1086 β 1086 β 29 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:) and an incremental delegate with reduce
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 35 β 35 β 35 β 36 β 65 β 68 β 68 β 28 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 30 β 35 β 43 β 46 β 48 β 52 β 52 β 28 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 28 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 28 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 23 β 23 β 23 β 23 β 23 β 23 β 23 β 28 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 1176 β 1182 β 1185 β 1190 β 1198 β 1200 β 1200 β 28 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 1061 β 1067 β 1072 β 1075 β 1080 β 1083 β 1083 β 28 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:completionHandler:) and for loop
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 40 β 42 β 43 β 43 β 72 β 75 β 75 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 356 β 368 β 375 β 386 β 400 β 407 β 407 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 23 β 24 β 24 β 24 β 24 β 24 β 24 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 1016 β 1023 β 1026 β 1032 β 1041 β 1048 β 1048 β 32 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 940 β 946 β 948 β 952 β 961 β 967 β 967 β 32 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:completionHandler:) and for loop inside withUnsafeBytes
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 40 β 42 β 43 β 43 β 44 β 74 β 74 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 370 β 580 β 591 β 599 β 607 β 613 β 614 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases β 5 β 5 β 5 β 5 β 5 β 5 β 5 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains β 3 β 3 β 3 β 3 β 3 β 3 β 3 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 23 β 23 β 24 β 24 β 24 β 24 β 24 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 210 β 213 β 215 β 217 β 220 β 236 β 238 β 100 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 133 β 135 β 137 β 138 β 140 β 153 β 154 β 100 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:completionHandler:) and forEach
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 41 β 42 β 42 β 43 β 71 β 75 β 75 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 332 β 364 β 370 β 384 β 415 β 418 β 418 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 23 β 24 β 24 β 24 β 24 β 24 β 24 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 1243 β 1253 β 1258 β 1268 β 1270 β 1277 β 1277 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 1164 β 1175 β 1179 β 1188 β 1190 β 1201 β 1201 β 26 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
bytewise read using dataTask(with:completionHandler:) and reduce
ββββββββββββββββββββββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ€ββββββββββ
β Metric β p0 β p25 β p50 β p75 β p90 β p99 β p100 β Samples β
ββββββββββββββββββββββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββͺββββββββββ‘
β Malloc (total) (K) β 40 β 42 β 42 β 43 β 72 β 75 β 75 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Memory (resident peak) (M) β 353 β 392 β 416 β 452 β 472 β 473 β 473 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Releases (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Retains (K) β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 4194 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Syscalls (total) (K) β 23 β 24 β 24 β 24 β 24 β 24 β 24 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (total CPU) (ms) β 1241 β 1250 β 1254 β 1266 β 1278 β 1281 β 1281 β 26 β
ββββββββββββββββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββΌββββββββββ€
β Time (wall clock) (ms) β 1164 β 1172 β 1176 β 1185 β 1195 β 1200 β 1200 β 26 β
ββββββββββββββββββββββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ§ββββββββββ
βοΈ I didn’t include it in these initial results, but there’s also enumerateBytes
, carried over from NSData
. It performs identically to withUnsafeBytes
. However, it is officially deprecated (Apple claims that for-loops are the replacement, even though they’re an order of magnitude slower π€¨).
π€ I also tried to test the NSData
bytes
property, but no matter how it’s used, it always results in the benchmark crashing. It seems like it is actually unusable from Swift due to a memory management bug in the bridging layer and/or Swift compilerβ¦?
Observations
Incremental reads + withUnsafeBytes is unequivocally the best method
It’s dramatically faster than any other approach – both in wall time and overall CPU usage – and uses the least amount of memory by far.
Within the Data
-centric methods this doesn’t surprise me – with the incremental approach URLSession
can just hand data back as it comes in, in whatever chunk sizes are most convenient. In the other Data
-based approaches it has to aggregate everything into one final contiguous blob.
π€ This is all assuming that URLSession
never memory-maps files, which I did not actually verify but does seem to be the case based on the performance and behaviour. This strikes me as very odd, however, because memory-mapping the files would very likely be significantly faster, in the cases where it has to provide the entire contents as a single Data
instance. And Data
already supports memory-mapping a file, very easily.
Of course, if your use-case doesn’t involve local files, then memory-mapping probably doesn’t apply anyway (unless URLSession
uses a disk cache and the file is already in the cache – but I don’t know if it supports that).
Implementation note
I utilised the incremental API by basically adapting it to invoke a closure (shown below), mainly because it made it easier to then test different byte enumeration approaches within it, but the results should hold for typical implementations of URLSessionDataDelegate
.
β οΈ This isn’t a robust implementation; it’s not suitable for use in a real program, merely sufficient for this very specific application in these benchmarks. It doesn’t communicate failures correctly, behaves very poorly if misused (e.g. by using it for more than one operation), naively blocks the thread that’s awaiting the data, etc. Please don’t use it as-is, but feel free to evolve it into a real solution for your own uses.
class IncrementalDataDelegate: NSObject, URLSessionDataDelegate {
private let task: URLSessionTask
private let handler: (Data) -> ()
private let done = NSCondition()
init(_ task: URLSessionTask,
handler: @escaping (Data) -> ()) {
self.task = task
self.handler = handler
super.init()
}
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
precondition(self.task == dataTask)
self.handler(data)
}
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: (any Error)?) {
precondition(self.task == task)
if let error {
preconditionFailure("Error: \(error)")
}
self.done.broadcast()
}
func wait() {
self.done.wait()
}
}
AsyncBytes (bytes(from:)) is surprisingly not bad – in this specific case
This was surprising to me because generally I’ve seen Swift’s AsyncSequence
stuff – especially for operating on individual bytes – being unusably slow and inefficient. It’s actually what prompted me to do these benchmarks, because I stubbornly tried using bytes(from:)
in a current project and the performance in that real app was god-awful. These benchmarks demonstrate that it doesn’t necessarily have to be, and there’s something more complicated going on. I’m yet to get to the bottom of that.
The problem seems to be that async code in general – but especially anything involving AsyncSequence
s – is terribly dependent on the compiler’s optimiser. If the optimiser does anything less than an astounding job on it, the performance can drop off a cliff.
So, while these results nominally recommend bytes(from:)
as a decent way to use URLSession
– being a respectable second-fastest in these benchmarks and noticeably easier to use than the fastest method – I’d be very cautious about it and test the performance early and often.
withUnsafeBytes
is way faster than “safe” access to Data
‘s contents
It’s an order of magnitude faster an Apple Silicon, and ‘merely’ seven to nine times faster on Intel.
This isn’t surprising – Data
‘s regular APIs involve actual function calls (if not also Objective-C message sends, depending on what exactly is being returned by URLSession
(native Data
or actual NSData
) and how Swift imports NSData
from Objective-C. withUnsafeBytes
provides basically direct memory access, with practically zero overhead.
However, it has one notable downsideβ¦
withUnsafeBytes
doubles the memory usage of the target Data
This surprised and disappointed me – Data
is supposed to already be a contiguous array of bytes, internally, so accessing those bytes with withUnsafeBytes
should be nothing more than returning a pointer to that internal storage. But in at least some cases, it doesn’t – instead, it allocates a whole new memory allocation, copies its contents to that allocation, and then provides that instead (and releases it afterwards – so repeated calls will incur this overhead every time).
This isn’t a huge issue when the Data
s in question are small – clearly it doesn’t hamper performance all that much, since it’s still the fastest way to access the bytes of even a 128 MiB Data
– but it can be an issue when the Data
s in question are not small. If you run out of free RAM, the cost of the kernel’s in-memory compression or swapping is very likely going to cripple the performance far beyond the degrees seen here by using the slow APIs.
Reading a file with URLSession takes more than one CPU core
I pointedly included both wall time and CPU time to highlight that there’s multiple cores engaged simultaneously for a single read. This isn’t surprising, but it’s important to remember if you’re doing lots of parallel I/O – you can’t just naively allocate one read operation per CPU core and expect linear scaling (notwithstanding CPU frequency scaling etc anyway).
Though, that’s generally true anyway because most systems don’t have enough disk or network I/O to keep up with the CPU anyway.
for loops are faster than forEach
& reduce
This might surprise some folks. It’s surely a bit of a sore point with functional programming dogmatists. The difference isn’t massive – in these benchmarks it’s only about 20%. Still, it’s measurable and noticeable.
I find the for-loop approach easier to write and read anyway, so IMO this is just another reason to favour that instead of functional programming styles. But not a reason to unilaterally favour one over the other.
forEach
& reduce
perform the same
Not surprising or news, but worth noting. In principle the optimiser should reduce them to the exact same machine code in the end.
Similar performance characteristics between [old] Intel Xeons and Apple Silicon
The M2 was faster, of course, but maybe not as much faster than one would expect – at best only twice as fast, which (subjectively) feels underwhelming given Apple’s numerous manufacturing and design advantages versus my iMac Pro’s old Xeon.
What I mean, though, is that the relative performance of the different methods is about the same irrespective of the platform. What’s good (or bad) on an M2 is likewise on an Intel CPU. Which is worth appreciating – although x86 is rapidly fading into irrelevance, it’s not quite there yet, and it’s always unpleasant when optimising for one architecture has the opposite effect on another.
You’re probably not going to be I/O limited on Apple SSDs
(for a single read at a time, that is)
Even in the very best case shown here – and despite the very light workload these benchmarks impose, on the actual file data – the best throughput was merely ~3.6 GB/s. That’s not bad, of course – only a few years ago that would have easily saturated any consumer storage device, even a big Thunderbolt RAID array of SSDs. But these days most of Apple’s computers have PCIe 4, quad-lane SSDs that have read speeds of about 7 GB/s.
And, this is all ignoring the fact that actually reading from an SSD has more overhead than merely reading from the kernel’s file system cache, as these benchmarks almost certainly did. So actual SSD read performance is very likely lower than what these benchmarks achieved.
That all said, it doesn’t necessarily take much to be I/O-limited – two or three concurrent reads, efficiently implemented, would probably do it. Certainly if you just spin up an operation per CPU core and they all try to do I/O at once, even a rather inefficient implementation will hit the SSD’s limits.