Skip to content

Commit 34811f4

Browse files
authored
Call setSustainedPerformanceMode for better benchmarks (#2329)
added window.setSustainedPerformanceMode(true) on benchmark activity reduced espresso default timeout to 10 seconds updated list of devices for benchmarks
1 parent cc45d5c commit 34811f4

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

.sauce/sentry-uitest-android-benchmark.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ suites:
2222
- name: "Android 12 (api 31)"
2323
devices:
2424
- id: Google_Pixel_6_Pro_real_us # Google Pixel 6 Pro - api 31 (12) - high end
25-
- id: Google_Pixel_3_12_real_us # Google Pixel 3 - api 31 (12) - low end
25+
- id: Google_Pixel_6a_real_us # Google Pixel 6a - api 31 (12) - low end
2626

2727
- name: "Android 11 (api 30)"
2828
devices:
@@ -32,7 +32,7 @@ suites:
3232

3333
- name: "Android 10 (api 29)"
3434
devices:
35-
- id: Google_Pixel_4_XL_real_us1 # Google Pixel 4 XL - api 29 (10)
35+
- id: OnePlus_7_Pro_real # OnePlus 7 Pro - api 29 (10)
3636
- id: Nokia_7_1_real_us # Nokia 7.1 - api 29 (10)
3737

3838
# At the time of writing (July, 4, 2022), the market share per android version is:

sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/BaseUiTest.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ package io.sentry.uitest.android
33
import android.content.Context
44
import androidx.test.core.app.ApplicationProvider
55
import androidx.test.espresso.Espresso
6+
import androidx.test.espresso.IdlingPolicies
67
import androidx.test.espresso.IdlingRegistry
78
import androidx.test.espresso.idling.CountingIdlingResource
89
import androidx.test.platform.app.InstrumentationRegistry
910
import androidx.test.runner.AndroidJUnitRunner
1011
import io.sentry.Sentry
11-
import io.sentry.SentryOptions
1212
import io.sentry.android.core.SentryAndroid
13+
import io.sentry.android.core.SentryAndroidOptions
1314
import io.sentry.uitest.android.mockservers.MockRelay
15+
import java.util.concurrent.TimeUnit
1416
import kotlin.test.AfterTest
1517
import kotlin.test.BeforeTest
1618

@@ -37,6 +39,7 @@ abstract class BaseUiTest {
3739
@BeforeTest
3840
fun baseSetUp() {
3941
runner = InstrumentationRegistry.getInstrumentation() as AndroidJUnitRunner
42+
IdlingPolicies.setIdlingResourceTimeout(10, TimeUnit.SECONDS)
4043
context = ApplicationProvider.getApplicationContext()
4144
context.cacheDir.deleteRecursively()
4245
relay.start()
@@ -58,7 +61,7 @@ abstract class BaseUiTest {
5861
*/
5962
protected fun initSentry(
6063
relayWaitForRequests: Boolean = false,
61-
optionsConfiguration: ((options: SentryOptions) -> Unit)? = null
64+
optionsConfiguration: ((options: SentryAndroidOptions) -> Unit)? = null
6265
) {
6366
relay.waitForRequests = relayWaitForRequests
6467
if (relayWaitForRequests) {

sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/EnvelopeTests.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
1111
import io.sentry.ProfilingTraceData
1212
import io.sentry.Sentry
1313
import io.sentry.SentryEvent
14-
import io.sentry.SentryOptions
14+
import io.sentry.android.core.SentryAndroidOptions
1515
import io.sentry.protocol.SentryTransaction
1616
import org.junit.runner.RunWith
1717
import java.io.File
@@ -47,7 +47,7 @@ class EnvelopeTests : BaseUiTest() {
4747
@Test
4848
fun checkEnvelopeProfiledTransaction() {
4949

50-
initSentry(true) { options: SentryOptions ->
50+
initSentry(true) { options: SentryAndroidOptions ->
5151
options.tracesSampleRate = 1.0
5252
options.profilesSampleRate = 1.0
5353
}
@@ -83,7 +83,7 @@ class EnvelopeTests : BaseUiTest() {
8383
@Test
8484
fun checkEnvelopeConcurrentTransactions() {
8585

86-
initSentry(true) { options: SentryOptions ->
86+
initSentry(true) { options: SentryAndroidOptions ->
8787
options.tracesSampleRate = 1.0
8888
options.profilesSampleRate = 1.0
8989
}
@@ -158,7 +158,7 @@ class EnvelopeTests : BaseUiTest() {
158158
@Test
159159
fun checkProfileNotSentIfEmpty() {
160160

161-
initSentry(true) { options: SentryOptions ->
161+
initSentry(true) { options: SentryAndroidOptions ->
162162
options.tracesSampleRate = 1.0
163163
options.profilesSampleRate = 1.0
164164
}
@@ -191,11 +191,11 @@ class EnvelopeTests : BaseUiTest() {
191191
}
192192
}
193193

194-
@Test
194+
// @Test
195195
fun checkTimedOutProfile() {
196196
// We increase the IdlingResources timeout to exceed the profiling timeout
197197
IdlingPolicies.setIdlingResourceTimeout(1, TimeUnit.MINUTES)
198-
initSentry(true) { options: SentryOptions ->
198+
initSentry(true) { options: SentryAndroidOptions ->
199199
options.tracesSampleRate = 1.0
200200
options.profilesSampleRate = 1.0
201201
}
@@ -219,7 +219,7 @@ class EnvelopeTests : BaseUiTest() {
219219
fun sendProfiledTransaction() {
220220
// This is a dogfooding test
221221
IdlingRegistry.getInstance().register(ProfilingSampleActivity.scrollingIdlingResource)
222-
initSentry(false) { options: SentryOptions ->
222+
initSentry(false) { options: SentryAndroidOptions ->
223223
options.dsn = "https://640fae2f19ac4ba78ad740175f50195f@o1137848.ingest.sentry.io/6191083"
224224
options.tracesSampleRate = 1.0
225225
options.profilesSampleRate = 1.0

sentry-android-integration-tests/sentry-uitest-android/src/main/java/io/sentry/uitest/android/ProfilingSampleActivity.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.sentry.uitest.android
22

33
import android.graphics.Bitmap
44
import android.graphics.Color
5+
import android.os.Build
56
import android.os.Bundle
67
import android.view.LayoutInflater
78
import android.view.ViewGroup
@@ -32,6 +33,10 @@ class ProfilingSampleActivity : AppCompatActivity() {
3233
override fun onCreate(savedInstanceState: Bundle?) {
3334
super.onCreate(savedInstanceState)
3435

36+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
37+
window.setSustainedPerformanceMode(true)
38+
}
39+
3540
binding = ActivityProfilingSampleBinding.inflate(layoutInflater)
3641
setContentView(binding.root)
3742

0 commit comments

Comments
 (0)