Add back iterator for Elements, count test iterations
This commit is contained in:
parent
ed6fec2809
commit
563e0c3476
|
@ -586,25 +586,25 @@ extension Elements: Equatable {
|
|||
/**
|
||||
* Elements RandomAccessCollection
|
||||
*/
|
||||
//extension Elements: RandomAccessCollection {
|
||||
// public subscript(position: Int) -> Element {
|
||||
// return this[position]
|
||||
// }
|
||||
//
|
||||
// public var startIndex: Int {
|
||||
// return this.startIndex
|
||||
// }
|
||||
//
|
||||
// public var endIndex: Int {
|
||||
// return this.endIndex
|
||||
// }
|
||||
//
|
||||
// /// The number of Element objects in the collection.
|
||||
// /// Equivalent to `size()`
|
||||
// public var count: Int {
|
||||
// return this.count
|
||||
// }
|
||||
//}
|
||||
extension Elements: RandomAccessCollection {
|
||||
public subscript(position: Int) -> Element {
|
||||
return this[position]
|
||||
}
|
||||
|
||||
public var startIndex: Int {
|
||||
return this.startIndex
|
||||
}
|
||||
|
||||
public var endIndex: Int {
|
||||
return this.endIndex
|
||||
}
|
||||
|
||||
/// The number of Element objects in the collection.
|
||||
/// Equivalent to `size()`
|
||||
public var count: Int {
|
||||
return this.count
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Elements IteratorProtocol.
|
||||
|
|
|
@ -23,16 +23,19 @@ class ParserBenchmark: XCTestCase {
|
|||
}
|
||||
|
||||
func testParserPerformance() throws {
|
||||
var count = 0
|
||||
measure {
|
||||
for htmlDoc in Const.corpusHTMLData {
|
||||
for _ in 1...Const.repetitions {
|
||||
do {
|
||||
let _ = try SwiftSoup.parse(htmlDoc)
|
||||
count += 1
|
||||
} catch {
|
||||
XCTFail("Exception while parsing HTML")
|
||||
}
|
||||
}
|
||||
}
|
||||
print("Did \(count) iterations")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue