Add back iterator for Elements, count test iterations

This commit is contained in:
Garth Snyder 2019-12-19 18:01:46 -08:00
parent ed6fec2809
commit 563e0c3476
2 changed files with 22 additions and 19 deletions

View File

@ -586,25 +586,25 @@ extension Elements: Equatable {
/** /**
* Elements RandomAccessCollection * Elements RandomAccessCollection
*/ */
//extension Elements: RandomAccessCollection { extension Elements: RandomAccessCollection {
// public subscript(position: Int) -> Element { public subscript(position: Int) -> Element {
// return this[position] return this[position]
// } }
//
// public var startIndex: Int { public var startIndex: Int {
// return this.startIndex return this.startIndex
// } }
//
// public var endIndex: Int { public var endIndex: Int {
// return this.endIndex return this.endIndex
// } }
//
// /// The number of Element objects in the collection. /// The number of Element objects in the collection.
// /// Equivalent to `size()` /// Equivalent to `size()`
// public var count: Int { public var count: Int {
// return this.count return this.count
// } }
//} }
/** /**
* Elements IteratorProtocol. * Elements IteratorProtocol.

View File

@ -23,16 +23,19 @@ class ParserBenchmark: XCTestCase {
} }
func testParserPerformance() throws { func testParserPerformance() throws {
var count = 0
measure { measure {
for htmlDoc in Const.corpusHTMLData { for htmlDoc in Const.corpusHTMLData {
for _ in 1...Const.repetitions { for _ in 1...Const.repetitions {
do { do {
let _ = try SwiftSoup.parse(htmlDoc) let _ = try SwiftSoup.parse(htmlDoc)
count += 1
} catch { } catch {
XCTFail("Exception while parsing HTML") XCTFail("Exception while parsing HTML")
} }
} }
} }
print("Did \(count) iterations")
} }
} }