Skip to content

Commit 03255bd

Browse files
authored
Merge pull request #2 from davecom/master
Merge updated master
2 parents 4d35c48 + 51208e0 commit 03255bd

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

Tests/SwiftPriorityQueueTests/SwiftPriorityQueuePerformanceTests.swift

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,45 +24,47 @@ import XCTest
2424
@testable import SwiftPriorityQueue
2525

2626
class SwiftPriorityQueuePerformanceTests: XCTestCase {
27-
28-
func testBuildPerformance() {
29-
let input: [Int] = Array((0 ..< 100000))
30-
measure {
27+
28+
func testBuildPerformance() {
29+
let input: [Int] = Array((0 ..< 100000))
30+
measure {
3131
let _: PriorityQueue<Int> = PriorityQueue(ascending: true, startingValues: input)
32-
}
33-
}
34-
35-
func testPopPerformance() {
36-
var pq = PriorityQueue(ascending: true, startingValues: Array(0 ..< 100000))
32+
}
33+
}
34+
35+
func testPopPerformance() {
36+
let original = PriorityQueue(ascending: true, startingValues: Array(0 ..< 100000))
37+
measure {
38+
var pq = original
39+
for _ in 0 ..< 100000 {
40+
let _ = pq.pop()
41+
}
42+
}
43+
}
44+
45+
func testPushPerformance() {
3746
measure {
38-
for _ in 0 ..< 100000 {
39-
let _ = pq.pop()
40-
}
41-
}
42-
}
43-
44-
func testPushPerformance() {
45-
var pq = PriorityQueue<Int>(ascending: true, startingValues: [])
46-
measure {
47-
for i in 0 ..< 100000 {
48-
pq.push(i)
49-
}
50-
}
51-
}
52-
53-
func testRemovePerformance() {
54-
var pq = PriorityQueue(ascending: true, startingValues: Array(0 ..< 10000))
55-
measure {
47+
for i in 0 ..< 100000 {
48+
var pq = PriorityQueue<Int>(ascending: true, startingValues: [])
49+
pq.push(i)
50+
}
51+
}
52+
}
53+
54+
func testRemovePerformance() {
55+
let original = PriorityQueue(ascending: true, startingValues: Array(0 ..< 10000))
56+
measure {
57+
var pq = original
5658
for x in 0 ..< 100 {
57-
pq.remove(x * x)
58-
}
59-
}
60-
}
61-
59+
pq.remove(x * x)
60+
}
61+
}
62+
}
63+
6264
static var allTests = [
63-
("testBuildPerformance", testBuildPerformance),
64-
("testPopPerformance", testPopPerformance),
65-
("testPushPerformance", testPushPerformance),
66-
("testRemovePerformance", testRemovePerformance)
65+
("testBuildPerformance", testBuildPerformance),
66+
("testPopPerformance", testPopPerformance),
67+
("testPushPerformance", testPushPerformance),
68+
("testRemovePerformance", testRemovePerformance)
6769
]
6870
}

0 commit comments

Comments
 (0)