Skip to content

Commit 887d20c

Browse files
committed
Revert "Add performance test case for JSON serialization"
This reverts commit 867109e.
1 parent 867109e commit 887d20c

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

TestFoundation/TestNSJSONSerialization.swift

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import SwiftFoundation
1616
import SwiftXCTest
1717
#endif
18-
import Dispatch
18+
1919

2020
class TestNSJSONSerialization : XCTestCase {
2121

@@ -598,7 +598,6 @@ extension TestNSJSONSerialization {
598598
("test_invalidJsonObjectToStreamBuffer", test_invalidJsonObjectToStreamBuffer),
599599
("test_jsonObjectToOutputStreamInsufficeintBuffer", test_jsonObjectToOutputStreamInsufficeintBuffer),
600600
("test_booleanJSONObject", test_booleanJSONObject),
601-
("test_serialization_perf", test_serialize_perf),
602601
]
603602
}
604603

@@ -744,35 +743,6 @@ extension TestNSJSONSerialization {
744743
XCTAssertEqual(try trySerialize(jsonArr4), "[{\"a\":null},{\"b\":null}]")
745744
}
746745

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-
776746
func test_nested_array() {
777747
var arr: [Any] = ["a"]
778748
XCTAssertEqual(try trySerialize(arr), "[\"a\"]")

0 commit comments

Comments
 (0)