Skip to content

Commit 8b040e4

Browse files
authored
test: generate profiles with different levels of efficiency (#2274)
1 parent 3861500 commit 8b040e4

File tree

6 files changed

+86
-61
lines changed

6 files changed

+86
-61
lines changed

Brewfile.lock.json

Lines changed: 32 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -55,35 +55,25 @@
5555
}
5656
},
5757
"swiftlint": {
58-
"version": "0.47.1",
58+
"version": "0.49.1",
5959
"bottle": {
6060
"rebuild": 0,
6161
"root_url": "https://ghcr.io/v2/homebrew/core",
6262
"files": {
6363
"arm64_monterey": {
6464
"cellar": ":any_skip_relocation",
65-
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:13b6b6d881b6cfa3f5399c14150ef6da0f1d1cec2b58fd24c6dcbc432c462106",
66-
"sha256": "13b6b6d881b6cfa3f5399c14150ef6da0f1d1cec2b58fd24c6dcbc432c462106"
67-
},
68-
"arm64_big_sur": {
69-
"cellar": ":any_skip_relocation",
70-
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:406fb7b019a5b7f0c052a7d4738f6cda5eaf15ef9c1bc1f89bdc3dc2efc719b6",
71-
"sha256": "406fb7b019a5b7f0c052a7d4738f6cda5eaf15ef9c1bc1f89bdc3dc2efc719b6"
65+
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:d983879e2d9ea075bf80e223da5adb258f01d9fab4fc6f71f83c4add80490290",
66+
"sha256": "d983879e2d9ea075bf80e223da5adb258f01d9fab4fc6f71f83c4add80490290"
7267
},
7368
"monterey": {
7469
"cellar": ":any_skip_relocation",
75-
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:3c02d2875bef6dbd474c60a4ce42cce5f9e1da64580c00c351753adeaece5700",
76-
"sha256": "3c02d2875bef6dbd474c60a4ce42cce5f9e1da64580c00c351753adeaece5700"
77-
},
78-
"big_sur": {
79-
"cellar": ":any_skip_relocation",
80-
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:775d4db3c21549bb18384be86ee82a43c92af12b74f9135e7b44f448cd6e0eff",
81-
"sha256": "775d4db3c21549bb18384be86ee82a43c92af12b74f9135e7b44f448cd6e0eff"
70+
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:73a9664d8a62c7b5d506a70bf100e0289795df04ece6df12f0b77651e497d42b",
71+
"sha256": "73a9664d8a62c7b5d506a70bf100e0289795df04ece6df12f0b77651e497d42b"
8272
},
8373
"x86_64_linux": {
8474
"cellar": "/home/linuxbrew/.linuxbrew/Cellar",
85-
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:f00160b4eb1d370d6baf4341341f813af80ba2fcfa2e65657f96153713d1c774",
86-
"sha256": "f00160b4eb1d370d6baf4341341f813af80ba2fcfa2e65657f96153713d1c774"
75+
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:705904346a73422be8f053d7b1c413e5d18623bd7244cb33d188d921a072e600",
76+
"sha256": "705904346a73422be8f053d7b1c413e5d18623bd7244cb33d188d921a072e600"
8777
}
8878
}
8979
}
@@ -172,40 +162,40 @@
172162
}
173163
},
174164
"pre-commit": {
175-
"version": "2.19.0",
165+
"version": "2.20.0",
176166
"bottle": {
177-
"rebuild": 0,
167+
"rebuild": 1,
178168
"root_url": "https://ghcr.io/v2/homebrew/core",
179169
"files": {
180170
"arm64_monterey": {
181-
"cellar": ":any",
182-
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:35830ae8dc83700b547c078a43e0cae5b99c69d820e6a70b7dd43872105cc075",
183-
"sha256": "35830ae8dc83700b547c078a43e0cae5b99c69d820e6a70b7dd43872105cc075"
171+
"cellar": ":any_skip_relocation",
172+
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:4a480973522d0180cfd1414ec3d31f8aa284f26243a89036098dd3343ace6a96",
173+
"sha256": "4a480973522d0180cfd1414ec3d31f8aa284f26243a89036098dd3343ace6a96"
184174
},
185175
"arm64_big_sur": {
186-
"cellar": ":any",
187-
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:ae925eb818c247559e36558216c63a5298653d65ecd528383340a0ee8b92c07e",
188-
"sha256": "ae925eb818c247559e36558216c63a5298653d65ecd528383340a0ee8b92c07e"
176+
"cellar": ":any_skip_relocation",
177+
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:cb061bc7f86b3149975d8bee8a209410c786d11ffa4091ad7769d6810a37ef5a",
178+
"sha256": "cb061bc7f86b3149975d8bee8a209410c786d11ffa4091ad7769d6810a37ef5a"
189179
},
190180
"monterey": {
191-
"cellar": ":any",
192-
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:fa8795f2fc5231708ac69b3447732d3342ac77084c75d4cd92636e4cb3306918",
193-
"sha256": "fa8795f2fc5231708ac69b3447732d3342ac77084c75d4cd92636e4cb3306918"
181+
"cellar": ":any_skip_relocation",
182+
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:b822f396ca2e6523195d6c17ac8bf41eb6aee2e7ceac2ac0c18fbfd708c6a3ab",
183+
"sha256": "b822f396ca2e6523195d6c17ac8bf41eb6aee2e7ceac2ac0c18fbfd708c6a3ab"
194184
},
195185
"big_sur": {
196-
"cellar": ":any",
197-
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:1eb31671ec49ce4703bdf821c46238a541ef5972f462174f4765dac8a2cf72c3",
198-
"sha256": "1eb31671ec49ce4703bdf821c46238a541ef5972f462174f4765dac8a2cf72c3"
186+
"cellar": ":any_skip_relocation",
187+
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:40508e1e583f42c3581c2488d8fcb4b88e4138bfb775e88041166ae8385f25a3",
188+
"sha256": "40508e1e583f42c3581c2488d8fcb4b88e4138bfb775e88041166ae8385f25a3"
199189
},
200190
"catalina": {
201-
"cellar": ":any",
202-
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:4852270ec8f9249be28101899cfc2f5718b8b5ac79432089484af3e754a075cf",
203-
"sha256": "4852270ec8f9249be28101899cfc2f5718b8b5ac79432089484af3e754a075cf"
191+
"cellar": ":any_skip_relocation",
192+
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:4bd415259c3ca8fe8255c8116865d88e5841cd618d9e75ddfdf04ce79c19e53d",
193+
"sha256": "4bd415259c3ca8fe8255c8116865d88e5841cd618d9e75ddfdf04ce79c19e53d"
204194
},
205195
"x86_64_linux": {
206196
"cellar": ":any_skip_relocation",
207-
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:6376d63fa6a158bd89dcf23bf75c6b684c542ca933c4c47e434287f92649cd17",
208-
"sha256": "6376d63fa6a158bd89dcf23bf75c6b684c542ca933c4c47e434287f92649cd17"
197+
"url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:95bb496c02885d65a8db70ad434fda479a99a146e0244308c9be91322b0a2dd3",
198+
"sha256": "95bb496c02885d65a8db70ad434fda479a99a146e0244308c9be91322b0a2dd3"
209199
}
210200
}
211201
}
@@ -215,12 +205,12 @@
215205
"system": {
216206
"macos": {
217207
"monterey": {
218-
"HOMEBREW_VERSION": "3.5.4",
219-
"HOMEBREW_PREFIX": "/usr/local",
220-
"Homebrew/homebrew-core": "5d8199d4653c34f7d06d716c762e23b19c27ffe3",
221-
"CLT": "13.0.0.0.1.1627064638",
222-
"Xcode": "13.4.1",
223-
"macOS": "12.4"
208+
"HOMEBREW_VERSION": "3.6.5",
209+
"HOMEBREW_PREFIX": "/opt/homebrew",
210+
"Homebrew/homebrew-core": "8953dee9c8266b88d45b1697cc931bdf0112342d",
211+
"CLT": "14.0.0.0.1.1661618636",
212+
"Xcode": "14.0",
213+
"macOS": "12.6"
224214
}
225215
}
226216
}

Gemfile.lock

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ GEM
33
specs:
44
CFPropertyList (3.0.5)
55
rexml
6-
activesupport (6.1.6.1)
6+
activesupport (6.1.7)
77
concurrent-ruby (~> 1.0, >= 1.0.2)
88
i18n (>= 1.6, < 2)
99
minitest (>= 5.1)
@@ -17,8 +17,8 @@ GEM
1717
artifactory (3.0.15)
1818
atomos (0.1.3)
1919
aws-eventstream (1.2.0)
20-
aws-partitions (1.636.0)
21-
aws-sdk-core (3.154.0)
20+
aws-partitions (1.644.0)
21+
aws-sdk-core (3.159.0)
2222
aws-eventstream (~> 1, >= 1.0.2)
2323
aws-partitions (~> 1, >= 1.525.0)
2424
aws-sigv4 (~> 1.1)
@@ -30,7 +30,7 @@ GEM
3030
aws-sdk-core (~> 3, >= 3.127.0)
3131
aws-sdk-kms (~> 1)
3232
aws-sigv4 (~> 1.4)
33-
aws-sigv4 (1.5.1)
33+
aws-sigv4 (1.5.2)
3434
aws-eventstream (~> 1, >= 1.0.2)
3535
babosa (1.0.4)
3636
claide (1.1.0)
@@ -86,7 +86,7 @@ GEM
8686
escape (0.0.4)
8787
ethon (0.15.0)
8888
ffi (>= 1.15.0)
89-
excon (0.92.5)
89+
excon (0.93.0)
9090
faraday (1.10.2)
9191
faraday-em_http (~> 1.0)
9292
faraday-em_synchrony (~> 1.0)
@@ -155,13 +155,13 @@ GEM
155155
xcodeproj (>= 1.13.0, < 2.0.0)
156156
xcpretty (~> 0.3.0)
157157
xcpretty-travis-formatter (>= 0.0.3)
158-
fastlane-plugin-sentry (1.13.0)
158+
fastlane-plugin-sentry (1.14.0)
159159
os (~> 1.1, >= 1.1.4)
160160
ffi (1.15.5)
161161
fourflusher (2.3.1)
162162
fuzzy_match (2.0.4)
163163
gh_inspector (1.1.3)
164-
google-apis-androidpublisher_v3 (0.28.0)
164+
google-apis-androidpublisher_v3 (0.29.0)
165165
google-apis-core (>= 0.9.0, < 2.a)
166166
google-apis-core (0.9.0)
167167
addressable (~> 2.5, >= 2.5.1)
@@ -176,19 +176,19 @@ GEM
176176
google-apis-core (>= 0.9.0, < 2.a)
177177
google-apis-playcustomapp_v1 (0.11.0)
178178
google-apis-core (>= 0.9.0, < 2.a)
179-
google-apis-storage_v1 (0.17.0)
180-
google-apis-core (>= 0.7, < 2.a)
179+
google-apis-storage_v1 (0.19.0)
180+
google-apis-core (>= 0.9.0, < 2.a)
181181
google-cloud-core (1.6.0)
182182
google-cloud-env (~> 1.0)
183183
google-cloud-errors (~> 1.0)
184184
google-cloud-env (1.6.0)
185185
faraday (>= 0.17.3, < 3.0)
186186
google-cloud-errors (1.3.0)
187-
google-cloud-storage (1.42.0)
187+
google-cloud-storage (1.43.0)
188188
addressable (~> 2.8)
189189
digest-crc (~> 0.4)
190190
google-apis-iamcredentials_v1 (~> 0.1)
191-
google-apis-storage_v1 (~> 0.17.0)
191+
google-apis-storage_v1 (~> 0.19.0)
192192
google-cloud-core (~> 1.6)
193193
googleauth (>= 0.16.2, < 2.a)
194194
mini_mime (~> 1.0)
@@ -282,7 +282,7 @@ GEM
282282
rouge (~> 2.0.7)
283283
xcpretty-travis-formatter (1.0.1)
284284
xcpretty (~> 0.2, >= 0.0.7)
285-
zeitwerk (2.6.0)
285+
zeitwerk (2.6.1)
286286

287287
PLATFORMS
288288
ruby
@@ -296,4 +296,4 @@ DEPENDENCIES
296296
xcpretty
297297

298298
BUNDLED WITH
299-
2.3.21
299+
2.3.23

Samples/TrendingMovies/ProfileDataGeneratorUITest/ProfileDataGeneratorUITest.m

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ - (void)testGenerateProfileData
2020
{
2121
CFTimeInterval const startTime = CACurrentMediaTime();
2222
CFTimeInterval const runDuration_seconds = 3.0 * 60.0;
23-
generateProfileData(5 /* nCellsPerTab */, YES /* clearState */);
23+
BOOL efficiently = NO;
24+
generateProfileData(5 /* nCellsPerTab */, YES /* clearState */, efficiently);
2425
while (true) {
2526
if ((CACurrentMediaTime() - startTime) >= runDuration_seconds) {
2627
break;
2728
}
28-
if (!generateProfileData(5 /* nCellsPerTab */, NO /* clearState */)) {
29+
efficiently = !efficiently;
30+
if (!generateProfileData(5 /* nCellsPerTab */, NO /* clearState */, efficiently)) {
2931
break;
3032
}
3133
}
@@ -36,15 +38,24 @@ - (void)testGenerateProfileData
3638
* Sentry transaction with profiling enabled.
3739
* @param nCellsPerTab The number of cells to tap on, per tab.
3840
* @param clearState Whether to clear filesystem state when the app starts.
41+
* @param efficiently Whether to perform certain operations in TrendingMovies using an efficient
42+
* method or not, to help us demonstrate how to identify such issues in the profiling areas of the
43+
* Sentry dashboard.
3944
* @return Whether the operation was successful or not.
4045
*/
4146
BOOL
42-
generateProfileData(NSUInteger nCellsPerTab, BOOL clearState)
47+
generateProfileData(NSUInteger nCellsPerTab, BOOL clearState, BOOL efficiently)
4348
{
4449
XCUIApplication *app = [[XCUIApplication alloc] init];
50+
NSMutableArray *launchArguments = app.launchArguments.mutableCopy;
4551
if (clearState) {
46-
app.launchArguments = @[ @"--clear" ];
52+
[launchArguments addObject:@"--clear"];
4753
}
54+
if (efficiently) {
55+
[launchArguments
56+
addObject:@"--io.sentry.sample.trending-movies.launch-arg.blur-images-on-bg-thread"];
57+
}
58+
app.launchArguments = launchArguments;
4859
[app launch];
4960
if (![app waitForState:XCUIApplicationStateRunningForeground timeout:kWaitForAppStateTimeout]) {
5061
XCTFail("App failed to transition to Foreground state");

Samples/TrendingMovies/TrendingMovies.xcodeproj/xcshareddata/xcschemes/TrendingMovies.xcscheme

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@
6060
ReferencedContainer = "container:TrendingMovies.xcodeproj">
6161
</BuildableReference>
6262
</BuildableProductRunnable>
63+
<CommandLineArguments>
64+
<CommandLineArgument
65+
argument = "--io.sentry.sample.trending-movies.blur-images-on-bg-thread"
66+
isEnabled = "NO">
67+
</CommandLineArgument>
68+
</CommandLineArguments>
6369
</LaunchAction>
6470
<ProfileAction
6571
buildConfiguration = "Release"

Samples/TrendingMovies/TrendingMovies/Movies/MovieCollectionViewCell.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import UIKit
44
class MovieCollectionViewCell: UICollectionViewCell {
55
static let reuseIdentifier = "MovieCollectionViewCell"
66
static let placeholderImageName = "MoviePosterPlaceholder"
7+
static let blurWorkQueue = DispatchQueue(label: "io.sentry.sample.trending-movies.queue.blur", qos: .utility, attributes: [.concurrent])
78

89
private struct Layout {
910
static let imageWidth: CGFloat = 170
@@ -150,6 +151,22 @@ class MovieCollectionViewCell: UICollectionViewCell {
150151
}
151152

152153
private func blurPosterImage(_ image: UIImage, completion: @escaping (UIImage?) -> Void) {
153-
let blurredImage = ImageEffects.createBlurredBackdrop(image: image, downsamplingFactor: 1.0, blurRadius: 20.0, tintColor: nil, saturationDeltaFactor: 2.0)
154-
completion(blurredImage)
154+
let efficiently = ProcessInfo.processInfo.arguments.contains("--io.sentry.sample.trending-movies.launch-arg.blur-images-on-bg-thread")
155+
func performBlur() {
156+
let blurredImage = ImageEffects.createBlurredBackdrop(image: image, downsamplingFactor: 1.0, blurRadius: 20.0, tintColor: nil, saturationDeltaFactor: 2.0)
157+
if efficiently {
158+
DispatchQueue.main.async {
159+
completion(blurredImage)
160+
}
161+
} else {
162+
completion(blurredImage)
163+
}
164+
}
165+
if efficiently {
166+
MovieCollectionViewCell.blurWorkQueue.async {
167+
performBlur()
168+
}
169+
} else {
170+
performBlur()
171+
}
155172
}

Samples/TrendingMovies/TrendingMovies/Utilities/Tracer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ extension Tracer {
4343

4444
SentrySDK.configureScope { scope in
4545
scope.setTag(value: setUpInDidFinishLaunching ? "didFinishLaunching" : "willFinishLaunching", key: "launch-method")
46+
scope.setTag(value: "\(ProcessInfo.processInfo.arguments.contains("--io.sentry.sample.trending-movies.launch-arg.blur-images-on-bg-thread"))", key: "efficient-implementation")
4647
}
4748
}
4849
}

0 commit comments

Comments
 (0)