Open weissi opened 1 week ago
For a simple PerfTester written like this
PerfTester
import SwiftExperimentalSubprocess import Foundation @main struct Main { static func main() async throws { let r = try await Subprocess.run( .at("/bin/bash"), arguments: ["-c", "cat"], input: .readFrom(.standardInput, closeAfterProcessSpawned: false) ) { p in var buffer: [UInt8] = [] buffer.reserveCapacity(1024 * 1024) for try await b in p.standardOutput { buffer.append(b) if buffer.count >= 1024 * 1024 { write(STDOUT_FILENO, buffer, buffer.count) buffer.removeAll(keepingCapacity: true) } } write(STDOUT_FILENO, buffer, buffer.count) } print(r) } }
compiled in release mode, that's the result
$ head -c "$((1 * 1024 * 1024))" /dev/zero | time .build/release/PerfTester > /dev/null 8.33 real 2.94 user 5.69 sys
which is 122 kB/s on my M2 Max machine. I would expect something between 1 and 3 GiB/s.
Apple folks: rdar://139888114
For a simple
PerfTester
written like thiscompiled in release mode, that's the result
which is 122 kB/s on my M2 Max machine. I would expect something between 1 and 3 GiB/s.