Skip to content

Commit 45fc945

Browse files
committed
Added debug logs to print map loading times.
1 parent 3eec0ee commit 45fc945

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

GoInfoGame/GoInfoGame/AppQuestManager.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,29 @@ class AppQuestManager {
7777
polyline.@count > 0 AND
7878
tags['ext:gig_complete'] != 'yes'
7979
""" ))
80-
80+
debugPrint("converting to nods: start \(Date())")
8181
let nodeElements = nodesFromStorage.map({ node in
8282
autoreleasepool {
8383
node.asNode()
8484
}
8585
})
86+
debugPrint("converting to nods: end \(Date())")
87+
debugPrint("converting to way: start \(Date())")
8688
let wayElements = waysFromStorage.map({ way in
8789
autoreleasepool {
8890
way.asWay()
8991
}
9092

9193
})
92-
94+
95+
debugPrint("converting to way: end \(Date())")
9396
// Get the quests for nodes
9497
var nodeQuests: [any Quest] = []
9598
var wayQuests: [any Quest] = []
9699
let allQuests = QuestsRepository.shared.applicableQuests
97100
var displayUnits : [DisplayUnitWithCoordinate] = []
98101

99-
102+
debugPrint("process nodes: start: \(Date())")
100103
// Get the quests for ways
101104
for node in nodeElements {
102105
// Get the quests and try to iterate
@@ -114,6 +117,8 @@ class AppQuestManager {
114117

115118
}
116119
}
120+
debugPrint("process nodes: end: \(Date())")
121+
debugPrint("process ways: start: \(Date())")
117122
for way in wayElements{
118123
for quest in allQuests {
119124
if quest.quest.filter.isEmpty {continue} // Ignore quest
@@ -129,6 +134,7 @@ class AppQuestManager {
129134
}
130135
}
131136
}
137+
debugPrint("process ways: end: \(Date())")
132138
print("Sending back items")
133139
print(allQuests)
134140

GoInfoGame/GoInfoGame/Network/ApiManager.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ApiManager {
6060
case .kartaview:
6161
finalUrl = APIConfiguration.shared.kartaViewUrl(for: endpoint)
6262
}
63-
63+
debugPrint("URL prepared \(Date())")
6464
guard let url = finalUrl else {
6565
print("Invalid URL")
6666
completion(.failure(APIError.invalidURL))
@@ -69,7 +69,7 @@ class ApiManager {
6969

7070
var request = URLRequest(url: url, timeoutInterval: Double.infinity)
7171
request.httpMethod = endpoint.method
72-
72+
debugPrint("URLRequest prepared \(Date())")
7373
if let formData = endpoint.formData {
7474
let boundary = "Boundary-\(UUID().uuidString)"
7575
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
@@ -117,14 +117,16 @@ class ApiManager {
117117
} else if let httpBody = endpoint.body {
118118
request.httpBody = httpBody
119119
}
120+
debugPrint("set body prepared \(Date())")
120121

121122
if let headers = endpoint.headers {
122123
for (key, value) in headers {
123124
request.setValue(value, forHTTPHeaderField: key)
124125
}
125126
}
126-
127+
debugPrint("set headders prepared \(url.path()) \(Date())")
127128
let task = URLSession.shared.dataTask(with: request) { [weak self] data, response, error in
129+
debugPrint("API raw response \(Date())")
128130
guard let self = self else {
129131
completion(.failure(APIError.custom("No data returned")))
130132
return

0 commit comments

Comments
 (0)