@jrose thanks for the quick response.
Yes, I have performed measurement test using XCTest.measure { }, although I don't have the baseline for this measurement, the numbers I see for linked list based implementation is better than the array implementation.
Heres the test code snippet for the test,
func test_OperationQueuePerformanceMeasurement() {
let priorities: [Operation.QueuePriority] = [ .veryHigh, .high, .normal, .low, .veryLow ]
let queue = OperationQueue()
queue.maxConcurrentOperationCount = 1
measure {
var operations = [Operation]()
for _ in 0...1000 {
let operation = BlockOperation(block: { })
operation.queuePriority = priorities.randomElement() ?? .normal
operations.append(operation)
}
queue.addOperations(operations, waitUntilFinished: true)
}
}
I tried measurement for both, current and linked list implementation, with 1000, 500, 100, 10 number of operations. The results are below,
Current Implementation
1000 Operations
average: 4.059
relative standard deviation: 5.279%
values: [4.118417, 3.810524, 4.005855, 4.614813, 4.090776, 3.996997, 4.058232, 3.924490, 4.024753, 3.948501]
maxPercentRelativeStandardDeviation: 10.000%
maxStandardDeviation: 0.100
500 Operations
average: 1.162
relative standard deviation: 3.986%
values: [1.194851, 1.218860, 1.120588, 1.189215, 1.196692, 1.087050, 1.196618, 1.098075, 1.175428, 1.145848]
maxPercentRelativeStandardDeviation: 10.000%
maxStandardDeviation: 0.100
10 Operations
average: 0.003
relative standard deviation: 8.285%
values: [0.003790, 0.003167, 0.003243, 0.003103, 0.003118, 0.003006, 0.002971, 0.003039, 0.002859, 0.002953]
maxPercentRelativeStandardDeviation: 10.000%
maxStandardDeviation: 0.100
--
Linked List Implementation
1000 Operations
average: 0.173
relative standard deviation: 3.914%
values: [0.178822, 0.180436, 0.178626, 0.180535, 0.165167, 0.163331, 0.176456, 0.174253, 0.168144, 0.166332]
maxPercentRelativeStandardDeviation: 10.000%
maxStandardDeviation: 0.100
500 Operations
average: 0.102
relative standard deviation: 3.473%
values: [0.101013, 0.097204, 0.096554, 0.107769, 0.104321, 0.102416, 0.104235, 0.106209, 0.101869, 0.102254]
maxPercentRelativeStandardDeviation: 10.000%
maxStandardDeviation: 0.100
100 Operations
average: 0.018
relative standard deviation: 4.641%
values: [0.017459, 0.017175, 0.017106, 0.017388, 0.018774, 0.019306, 0.018784, 0.019071, 0.018116, 0.018749]
maxPercentRelativeStandardDeviation: 10.000%
maxStandardDeviation: 0.100
10 Operations
average: 0.002
relative standard deviation: 6.390%
values: [0.002861, 0.002572, 0.002399, 0.002386, 0.002376, 0.002443, 0.002455, 0.002348, 0.002348, 0.002376]
maxPercentRelativeStandardDeviation: 10.000%
maxStandardDeviation: 0.100
--
Looking at the numbers, the trend Im seeing is that, as the number of operations increases, the linked list based implementation's performance looks better than array based implementation.
Hope Im doing the measurement correct, please correct me if Im wrong.