Skip to content

Commit cf0900d

Browse files
authored
[andr][tests] Profile Logger creation (#81)
1 parent fed6c3c commit cf0900d

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

platform/jvm/microbenchmark/src/androidTest/java/io/bitdrift/microbenchmark/ClockTimeProfiler.kt

+23-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
// LICENSE file or at:
66
// https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt
77

8+
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
9+
810
package io.bitdrift.microbenchmark
911

1012
import androidx.benchmark.junit4.BenchmarkRule
1113
import androidx.benchmark.junit4.measureRepeated
1214
import androidx.test.ext.junit.runners.AndroidJUnit4
1315
import io.bitdrift.capture.Capture
16+
import io.bitdrift.capture.Configuration
17+
import io.bitdrift.capture.LoggerImpl
18+
import io.bitdrift.capture.providers.SystemDateProvider
1419
import io.bitdrift.capture.providers.session.SessionStrategy
1520
import okhttp3.HttpUrl.Companion.toHttpUrl
16-
import org.junit.Before
1721
import org.junit.Rule
1822
import org.junit.Test
1923
import org.junit.runner.RunWith
@@ -32,24 +36,39 @@ class ClockTimeProfiler {
3236
@get:Rule
3337
val benchmarkRule = BenchmarkRule()
3438

35-
@Before
36-
fun setUp() {
39+
private fun startLogger() {
3740
Capture.Logger.start(
3841
apiKey = "android-benchmark-test",
3942
apiUrl = "https://api-tests.bitdrift.io".toHttpUrl(),
4043
sessionStrategy = SessionStrategy.Fixed(),
4144
)
4245
}
4346

47+
@Test
48+
fun loggerStart() {
49+
benchmarkRule.measureRepeated {
50+
LoggerImpl(
51+
apiKey = "android-benchmark-test",
52+
apiUrl = "https://api-tests.bitdrift.io".toHttpUrl(),
53+
fieldProviders = listOf(),
54+
dateProvider = SystemDateProvider(),
55+
configuration = Configuration(),
56+
sessionStrategy = SessionStrategy.Fixed(),
57+
)
58+
}
59+
}
60+
4461
@Test
4562
fun logNotMatchedNoFields() {
63+
startLogger()
4664
benchmarkRule.measureRepeated {
4765
Capture.Logger.logInfo { LOG_MESSAGE }
4866
}
4967
}
5068

5169
@Test
5270
fun logNotMatched5Fields() {
71+
startLogger()
5372
benchmarkRule.measureRepeated {
5473
Capture.Logger.logInfo(
5574
mapOf(
@@ -65,6 +84,7 @@ class ClockTimeProfiler {
6584

6685
@Test
6786
fun logNotMatched10Fields() {
87+
startLogger()
6888
benchmarkRule.measureRepeated {
6989
Capture.Logger.logInfo(
7090
mapOf(

0 commit comments

Comments
 (0)