             XCTAssertEqual(message, "Bad file descriptor")
         default:
             XCTFail()
+        }
+    }
+
+    func testWritePerformance() throws {
+        let inputURL = self.temporaryFileURL()
+        defer { self.removeFileIfExists(url: inputURL) }
+
+        let inputBytes = Array<UInt8>(repeating: 128, count: 128)
+
+        let stream = try FileOutputStream(url: inputURL, options: [.create])
+
+        self.measure {
+            for _ in 0..<100000 {
+
+                switch stream.write(inputBytes) {
+                case .success(_):
+                    break
+                default:
+                    XCTFail()
+                }
+            }
         }
     }
 

    func testWriteToFile() throws {
        let inputBytes = Array<UInt8>(repeating: 128, count: 10)

        let inputURL = self.temporaryFileURL()
        defer { self.removeFileIfExists(url: inputURL) }

        let stream = try FileOutputStream(url: inputURL, options: [.create])

        switch stream.write(inputBytes) {
        case .success(let written):
            XCTAssertEqual(written, 10)
            XCTAssertEqual(try Data(contentsOf: inputURL), Data(inputBytes))
        default:
            XCTFail()
        }
    }


                XCTFail("Error while deleting temporary file: \(error)")
            }
    }
}

