You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.4 KiB
77 lines
2.4 KiB
package net.pokeranalytics.android
|
|
|
|
import android.content.Context
|
|
import androidx.test.core.app.ApplicationProvider
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
import net.pokeranalytics.android.calculus.Calculator
|
|
import net.pokeranalytics.android.calculus.ComputableGroup
|
|
import net.pokeranalytics.android.calculus.ComputedResults
|
|
import net.pokeranalytics.android.calculus.Stat
|
|
import net.pokeranalytics.android.model.realm.ComputableResult
|
|
import net.pokeranalytics.android.model.realm.Session
|
|
import net.pokeranalytics.android.model.realm.SessionSet
|
|
import net.pokeranalytics.android.model.utils.Seed
|
|
import net.pokeranalytics.android.util.FakeDataManager
|
|
import org.junit.Test
|
|
import org.junit.runner.RunWith
|
|
import timber.log.Timber
|
|
|
|
/**
|
|
* Instrumented test, which will execute on an Android device.
|
|
*
|
|
* See [testing documentation](http://d.android.com/tools/testing).
|
|
*/
|
|
@RunWith(AndroidJUnit4::class)
|
|
class PerfsInstrumentedUnitTest : RealmInstrumentedUnitTest() {
|
|
|
|
@Test
|
|
fun testGlobalPerfs() {
|
|
|
|
Timber.d("*** start global perfs ")
|
|
|
|
|
|
val realm = mockRealm
|
|
val app: Context = ApplicationProvider.getApplicationContext()
|
|
|
|
realm.beginTransaction()
|
|
Seed(app).execute(realm)
|
|
realm.commitTransaction()
|
|
|
|
|
|
FakeDataManager.createFakeSessions(5000) {success ->
|
|
|
|
if (success) {
|
|
|
|
val start = System.currentTimeMillis()
|
|
|
|
val sessions = realm.where(Session::class.java).findAll()
|
|
val computableResults = realm.where(ComputableResult::class.java).findAll()
|
|
val sets = realm.where(SessionSet::class.java).findAll()
|
|
|
|
Timber.d("sessions: ${sessions.size}")
|
|
Timber.d("computableResults: ${computableResults.size}")
|
|
Timber.d("sets: ${sets.size}")
|
|
|
|
val stats: List<Stat> = listOf(Stat.NETRESULT, Stat.AVERAGE)
|
|
val group = ComputableGroup("test", computableResults, sets, stats)
|
|
|
|
val options = Calculator.Options()
|
|
options.displayedStats = listOf(Stat.STANDARD_DEVIATION_BB_PER_100_HANDS, Stat.STANDARD_DEVIATION)
|
|
|
|
val results: ComputedResults = Calculator.compute(group, options)
|
|
Timber.d("*** ended in ${System.currentTimeMillis() - start} milliseconds")
|
|
|
|
val sum = results.computedStat(Stat.NETRESULT)
|
|
Timber.d("*** NET RESULT: ${sum?.value}")
|
|
|
|
val average = results.computedStat(Stat.AVERAGE)
|
|
Timber.d("*** AVERAGE: ${average?.value}")
|
|
|
|
val duration = results.computedStat(Stat.DURATION)
|
|
Timber.d("*** DURATION: ${duration?.value}")
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
} |