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
|
* 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.
|
||||||
|
|
|
@ -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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue