Hello!
We are trying to add about 1 mln numbers and everything fine, but it takes in the range of 300-1900 seconds on iPhone X iOS 15.1
I wrote some code to measure time of specific code and noticied that every 10 000 number context.addIdentificationEntry
takes about 2-9 seconds although it usually takes about 0.00002 seconds.
Here is a code:
while reader.next() {
autoreleasepool {
numbersCount += 1
let phone = reader.phone
let name = reader.name
let startTime = DispatchTime.now()
context.addIdentificationEntry(withNextSequentialPhoneNumber: .init(phone), label: name ?? "")
let nanoTime = DispatchTime.now().uptimeNanoseconds - startTime.uptimeNanoseconds // <<<<< Difference in nano seconds (UInt64)
print("context.addIdentificationEntry() \(numbersCount) time: \(Double(nanoTime) / 1_000_000_000) seconds")
}
}
And some results:
context.addIdentificationEntry() 9998 time: 6.5e-06 seconds
context.addIdentificationEntry() 9999 time: 4.791e-06 seconds
context.addIdentificationEntry() 10000 time: 3.185010625 seconds
context.addIdentificationEntry() 10001 time: 7.85e-05 seconds
context.addIdentificationEntry() 10002 time: 6.458e-06 seconds
context.addIdentificationEntry() 19998 time: 5.542e-06 seconds
context.addIdentificationEntry() 19999 time: 6.958e-06 seconds
context.addIdentificationEntry() 20000 time: 11.186332542 seconds
context.addIdentificationEntry() 20001 time: 9.2833e-05 seconds
context.addIdentificationEntry() 20002 time: 1.6583e-05 seconds
Let's print only results which takes more than 1 seconds:
context.addIdentificationEntry() 10000 time: 3.331955583 seconds
context.addIdentificationEntry() 20000 time: 3.40216025 seconds
context.addIdentificationEntry() 30000 time: 3.972810084 seconds
context.addIdentificationEntry() 40001 time: 3.228795667 seconds
context.addIdentificationEntry() 50001 time: 2.544991 seconds
context.addIdentificationEntry() 60002 time: 2.030784791 seconds
context.addIdentificationEntry() 70002 time: 2.163966208 seconds
context.addIdentificationEntry() 80002 time: 1.995436209 seconds
...
context.addIdentificationEntry() 1110002 time: 1.514118458 seconds
context.addIdentificationEntry() 1120002 time: 1.474603625 seconds
context.addIdentificationEntry() 1130003 time: 1.539299917 seconds
context.addIdentificationEntry() 1140003 time: 1.046125458 seconds
So it takes too long to add 1 mln numbers. Sometimes it takes 250 sec, sometimes 1900 sec, don't know what it depends on