Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
// LICENSE file or at:
// https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt

@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package io.bitdrift.microbenchmark

import androidx.benchmark.junit4.BenchmarkRule
import androidx.benchmark.junit4.measureRepeated
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.bitdrift.capture.Capture
import io.bitdrift.capture.Configuration
import io.bitdrift.capture.LoggerImpl
import io.bitdrift.capture.providers.SystemDateProvider
import io.bitdrift.capture.providers.session.SessionStrategy
import okhttp3.HttpUrl.Companion.toHttpUrl
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -32,24 +36,39 @@ class ClockTimeProfiler {
@get:Rule
val benchmarkRule = BenchmarkRule()

@Before
fun setUp() {
private fun startLogger() {
Capture.Logger.start(
apiKey = "android-benchmark-test",
apiUrl = "https://api-tests.bitdrift.io".toHttpUrl(),
sessionStrategy = SessionStrategy.Fixed(),
)
}

@Test
fun loggerStart() {
benchmarkRule.measureRepeated {
LoggerImpl(
apiKey = "android-benchmark-test",
apiUrl = "https://api-tests.bitdrift.io".toHttpUrl(),
fieldProviders = listOf(),
dateProvider = SystemDateProvider(),
configuration = Configuration(),
sessionStrategy = SessionStrategy.Fixed(),
)
}
}

@Test
fun logNotMatchedNoFields() {
startLogger()
benchmarkRule.measureRepeated {
Capture.Logger.logInfo { LOG_MESSAGE }
}
}

@Test
fun logNotMatched5Fields() {
startLogger()
benchmarkRule.measureRepeated {
Capture.Logger.logInfo(
mapOf(
Expand All @@ -65,6 +84,7 @@ class ClockTimeProfiler {

@Test
fun logNotMatched10Fields() {
startLogger()
benchmarkRule.measureRepeated {
Capture.Logger.logInfo(
mapOf(
Expand Down
Loading