|
15 | 15 | import SwiftFoundation
|
16 | 16 | import SwiftXCTest
|
17 | 17 | #endif
|
18 |
| -import Dispatch |
| 18 | + |
19 | 19 |
|
20 | 20 | class TestNSJSONSerialization : XCTestCase {
|
21 | 21 |
|
@@ -598,7 +598,6 @@ extension TestNSJSONSerialization {
|
598 | 598 | ("test_invalidJsonObjectToStreamBuffer", test_invalidJsonObjectToStreamBuffer),
|
599 | 599 | ("test_jsonObjectToOutputStreamInsufficeintBuffer", test_jsonObjectToOutputStreamInsufficeintBuffer),
|
600 | 600 | ("test_booleanJSONObject", test_booleanJSONObject),
|
601 |
| - ("test_serialization_perf", test_serialize_perf), |
602 | 601 | ]
|
603 | 602 | }
|
604 | 603 |
|
@@ -744,35 +743,6 @@ extension TestNSJSONSerialization {
|
744 | 743 | XCTAssertEqual(try trySerialize(jsonArr4), "[{\"a\":null},{\"b\":null}]")
|
745 | 744 | }
|
746 | 745 |
|
747 |
| - func test_serialize_perf() { |
748 |
| - let numItems = 20 // Number of elements in the payload |
749 |
| - let loops = 500 // Number of times to invoke serialization per measurement |
750 |
| - let concurrency = 4 // Number of concurrent threads |
751 |
| - var PAYLOAD = [String:Any]() // The string to convert |
752 |
| - |
753 |
| - for i in 1...numItems { |
754 |
| - PAYLOAD["Item \(i)"] = Double(i) |
755 |
| - } |
756 |
| - |
757 |
| - let queue = DispatchQueue(label: "testcaseQueue", attributes: .concurrent) |
758 |
| - let group = DispatchGroup() |
759 |
| - |
760 |
| - self.measure { |
761 |
| - for _ in 1...concurrency { |
762 |
| - queue.async(group: group) { |
763 |
| - for _ in 1...loops { |
764 |
| - do { |
765 |
| - _ = try JSONSerialization.data(withJSONObject: PAYLOAD) |
766 |
| - } catch { |
767 |
| - XCTFail("Could not serialize to JSON: \(error)") |
768 |
| - } |
769 |
| - } |
770 |
| - } |
771 |
| - } |
772 |
| - _ = group.wait(timeout: .distantFuture) // forever |
773 |
| - } |
774 |
| - } |
775 |
| - |
776 | 746 | func test_nested_array() {
|
777 | 747 | var arr: [Any] = ["a"]
|
778 | 748 | XCTAssertEqual(try trySerialize(arr), "[\"a\"]")
|
|
0 commit comments