BenchmarkViewModel

class BenchmarkViewModel(val dispatchersProvider: DispatchersProvider, val benchmarkManager: BenchmarkManager, val router: BenchmarkRouter, val platformActions: BenchmarkPlatformActions, val onError: (Throwable) -> Unit = {}) : BaseMviViewModel<BenchmarkState, BenchmarkIntent, EmptyEffect> (source)

Coordinates benchmark screen state and safe benchmark execution.

The ViewModel never invokes model inference. It delegates to BenchmarkManager, which only reads hardware metadata and runs bounded synthetic CPU/memory work.

Author

Dmitriy Moroz

Constructors

Link copied to clipboard
constructor(dispatchersProvider: DispatchersProvider, benchmarkManager: BenchmarkManager, router: BenchmarkRouter, platformActions: BenchmarkPlatformActions, onError: (Throwable) -> Unit = {})

Properties

Link copied to clipboard
private val _effect: Channel<E>
Link copied to clipboard
private val _state: MutableStateFlow<S>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val effect: Flow<EmptyEffect>
Link copied to clipboard
private val effectDispatcher: CoroutineDispatcher
Link copied to clipboard
private val onError: (Throwable) -> Unit
Link copied to clipboard
Link copied to clipboard
private val router: BenchmarkRouter
Link copied to clipboard
open override val state: StateFlow<BenchmarkState>

Functions

Link copied to clipboard
expect open fun addCloseable(closeable: AutoCloseable)
expect fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
internal expect fun clear()
Link copied to clipboard
protected fun emitEffect(effect: EmptyEffect)
Link copied to clipboard
protected fun emitState(state: BenchmarkState)
Link copied to clipboard
expect fun <T : AutoCloseable> getCloseable(key: String): T?
Link copied to clipboard
private suspend fun handleFailure(throwable: Throwable)
Link copied to clipboard
protected fun launch(dispatcher: CoroutineDispatcher, start: CoroutineStart, block: suspend CoroutineScope.() -> Unit): Job
Link copied to clipboard
Link copied to clipboard
private fun observeBenchmarkData()
Link copied to clipboard
protected expect open fun onCleared()
Link copied to clipboard
open override fun processIntent(intent: BenchmarkIntent)
Link copied to clipboard
private fun refreshDevice()
Link copied to clipboard
private fun runBenchmark()
Link copied to clipboard
private fun shareResults()
Link copied to clipboard
protected fun updateState(mutation: (BenchmarkState) -> BenchmarkState)