11package io.sentry.uitest.android.benchmark
22
3- import android.content.Context
43import android.os.Bundle
54import androidx.lifecycle.Lifecycle
65import androidx.test.core.app.launchActivity
@@ -12,12 +11,6 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
1211import androidx.test.ext.junit.runners.AndroidJUnit4
1312import androidx.test.runner.AndroidJUnitRunner
1413import io.sentry.ITransaction
15- import io.sentry.Sentry
16- import io.sentry.Sentry.OptionsConfiguration
17- import io.sentry.SentryOptions
18- import io.sentry.android.core.SentryAndroid
19- import io.sentry.android.core.SentryAndroidOptions
20- import io.sentry.test.applyTestOptions
2114import io.sentry.uitest.android.benchmark.util.BenchmarkOperation
2215import kotlin.test.AfterTest
2316import kotlin.test.BeforeTest
@@ -71,49 +64,6 @@ class SentryBenchmarkTest : BaseBenchmarkTest() {
7164 // respectively.
7265 }
7366
74- @Test
75- fun benchmarkProfiledTransaction () {
76- // We compare the same operation with and without profiled transaction.
77- // We expect the profiled transaction operation to be slower, but not slower than 5%.
78- val benchmarkOperationNoTransaction =
79- BenchmarkOperation (choreographer, op = getOperation(runner))
80- val benchmarkOperationProfiled =
81- BenchmarkOperation (
82- choreographer,
83- before = {
84- runner.runOnMainSync {
85- initForTest(context) { options: SentryOptions ->
86- options.dsn = " https://key@uri/1234567"
87- options.tracesSampleRate = 1.0
88- options.profilesSampleRate = 1.0
89- options.isEnableAutoSessionTracking = false
90- }
91- }
92- },
93- op = getOperation(runner) { Sentry .startTransaction(" Benchmark" , " ProfiledTransaction" ) },
94- after = { runner.runOnMainSync { Sentry .close() } },
95- )
96- val refreshRate = BenchmarkActivity .refreshRate ? : 60F
97- val comparisonResults =
98- BenchmarkOperation .compare(
99- benchmarkOperationNoTransaction,
100- " NoTransaction" ,
101- benchmarkOperationProfiled,
102- " ProfiledTransaction" ,
103- refreshRate,
104- measuredIterations = 40 ,
105- )
106- comparisonResults.printAllRuns(" Profiling Benchmark" )
107- val comparisonResult = comparisonResults.getSummaryResult()
108- comparisonResult.printResults()
109-
110- // Currently we just want to assert the cpu overhead
111- assertTrue(
112- comparisonResult.cpuTimeIncreasePercentage in 0F .. 5.5F ,
113- " Expected ${comparisonResult.cpuTimeIncreasePercentage} to be in range 0 < x < 5.5" ,
114- )
115- }
116-
11767 /* *
11868 * Operation that will be compared: it launches [BenchmarkActivity], swipe the list and closes it.
11969 * The [transactionBuilder] is used to create the transaction before the swipes.
@@ -149,13 +99,3 @@ class SentryBenchmarkTest : BaseBenchmarkTest() {
14999 }
150100 }
151101}
152-
153- fun initForTest (
154- context : Context ,
155- optionsConfiguration : OptionsConfiguration <SentryAndroidOptions >,
156- ) {
157- SentryAndroid .init (context) {
158- applyTestOptions(it)
159- optionsConfiguration.configure(it)
160- }
161- }
0 commit comments