added div storage performance tests

added div storage performance tests
This commit is contained in:
edubinskaya
2023-03-10 14:58:26 +03:00
parent 29d4075a06
commit 02bffbf87f
4 changed files with 99 additions and 11 deletions
@@ -2,6 +2,7 @@ package com.yandex.div.storage.histogram
import androidx.annotation.AnyThread
import com.yandex.div.core.annotations.Mockable
import com.yandex.div.histogram.HistogramCallType
import com.yandex.div.histogram.HistogramFilter
import com.yandex.div.histogram.reporter.HistogramReporter
import com.yandex.div.histogram.reporter.HistogramReporterDelegate
@@ -41,23 +42,21 @@ internal class HistogramRecorder(
histogramName: String,
time: Long,
filter: HistogramFilter = HistogramFilter.ON,
) = histogramReporter.reportDuration(
histogramName = getFullHistogramName(histogramName),
) =
histogramReporter.reportDuration(
histogramName = histogramName,
duration = time,
componentName = histogramNameProvider?.componentName,
filter = filter
filter = filter,
forceCallType = getHistogramCallType(histogramName),
)
private fun getFullHistogramName(histogramName: String): String {
val callType = if (recordedHistograms.add(histogramName)) {
histogramNameProvider?.coldCallTypeSuffix
private fun getHistogramCallType(histogramName: String): String {
return if (recordedHistograms.add(histogramName)) {
histogramNameProvider?.coldCallTypeSuffix ?: HistogramCallType.CALL_TYPE_COLD
} else {
histogramNameProvider?.hotCallTypeSuffix
histogramNameProvider?.hotCallTypeSuffix ?: HistogramCallType.CALL_TYPE_WARM
}
return StringBuilder(histogramName).apply {
callType?.let { append(".$it") }
}.toString()
}
fun reportTemplatesParseTime(parsingHistogramNames: Set<String>, duration: Long) {
@@ -1,5 +1,6 @@
package com.yandex.divkit.demo.divstorage
import com.yandex.div.histogram.HistogramCallType
import com.yandex.div.storage.histogram.HistogramNameProvider
/**
@@ -27,6 +28,14 @@ class DemoAppHistogramNameProvider: HistogramNameProvider {
* Base name for templates parsing histogram.
*/
override val divParsingHistogramName: String = "Storage.Templates.Parsing"
/**
* Display suffix in report for first start.
*/
override val coldCallTypeSuffix: String get() = HistogramCallType.CALL_TYPE_COLD
/**
* Display suffix in report for hot start.
*/
override val hotCallTypeSuffix: String get() = HistogramCallType.CALL_TYPE_WARM
//currently used only as component name
override fun getHistogramNameFromCardId(cardId: String): String = componentName
@@ -0,0 +1,79 @@
package com.yandex.morda.perftests.div
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import com.yandex.divkit.perftests.divStorageBenchmarkActivityExtras
import com.yandex.divkit.perftests.DIV_STORAGE_BENCHMARK_ACTIVITY
import com.yandex.divkit.perftests.PACKAGE_NAME
import com.yandex.divkit.perftests.report
import com.yandex.divkit.perftests.startActivity
import com.yandex.perftests.runner.PerfTest
import com.yandex.perftests.runner.PerfTestJUnit4Runner
import com.yandex.perftests.runner.PerfTestParameter
import com.yandex.perftests.runner.PerfTestUtils
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(PerfTestJUnit4Runner::class)
@PerfTest(
packageName = PACKAGE_NAME,
description = "Div storage loading test",
owners = ["edubinskaya", "i-ts", "bgubanov"],
defaultRepeat = 20,
timeoutSeconds = 1200
)
class DivStorageCardsLoadTest {
private val utils = PerfTestUtils(PACKAGE_NAME)
@Before
fun setUp() {
utils.forceStop()
}
@PerfTestParameter(
requiredMetrics = [
"Storage.Data.Load.Cold",
"Storage.Templates.Parsing.Cold"
]
)
@Test
fun withTemplates() {
utils.run {
report(packageName = PACKAGE_NAME, tag = "with_templates") {
startActivity(
packageName = PACKAGE_NAME,
activityClass = DIV_STORAGE_BENCHMARK_ACTIVITY,
extras = divStorageBenchmarkActivityExtras(
assetNames = arrayOf("div2-perf/benchmark-with-templates.json",
"div2-perf/state-benchmark-multiple-change.json")
),
waitCondition = Until.findObject(By.textContains("Finished"))
)
}
}
}
@PerfTestParameter(
requiredMetrics = [
"Storage.Data.Load.Cold"
]
)
@Test
fun withoutTemplates() {
utils.run {
report(packageName = PACKAGE_NAME, tag = "without_templates") {
startActivity(
packageName = PACKAGE_NAME,
activityClass = DIV_STORAGE_BENCHMARK_ACTIVITY,
extras = divStorageBenchmarkActivityExtras(
assetNames = arrayOf("div2-perf/benchmark-without-templates.json",
"div2-perf/state-benchmark-multiple-change.json")
),
waitCondition = Until.findObject(By.textContains("Finished"))
)
}
}
}
}
@@ -0,0 +1 @@
divkit-android/c263fb9713f91dead24cd759a31aec3cfc7dcaec-com.yandex.morda.perftests.div.DivStorageCardsLoadTest.wprgo