Skip to content

Commit

Permalink
Merge branch 'master' into fix-sync-state-excepiton
Browse files Browse the repository at this point in the history
Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>
  • Loading branch information
ellykits committed Jun 20, 2023
2 parents a0326af + 80ea66f commit c60eeba
Show file tree
Hide file tree
Showing 251 changed files with 24,898 additions and 2,024 deletions.
5 changes: 1 addition & 4 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# Owners of the repository
* @aditya-07 @deepankarb @jingtang10 @jjtswan @kevinmost @ktarasenko @omarismail94 @stevenckngaa @vvikramraj @wantingzhang77 @yigit
# Owners of SDC library and catalog app
catalog/ @aditya-07 @deepankarb @jingtang10 @jjtswan @joiskash @kevinmost @ktarasenko @omarismail94 @santosh-pingle @stevenckngaa @vvikramraj @wantingzhang77 @yigit
datacapture/ @aditya-07 @deepankarb @jingtang10 @jjtswan @joiskash @kevinmost @ktarasenko @omarismail94 @santosh-pingle @stevenckngaa @vvikramraj @wantingzhang77 @yigit
* @google/android-fhir @santosh-pingle
12 changes: 8 additions & 4 deletions benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ android {
targetSdk = Sdk.targetSdk

testInstrumentationRunner = "androidx.benchmark.junit4.AndroidBenchmarkRunner"
// Runs only once
testInstrumentationRunnerArguments["androidx.benchmark.dryRunMode.enable"] = "true"
// Includes Startup time
testInstrumentationRunnerArguments["androidx.benchmark.startupMode.enable"] = "true"
testInstrumentationRunnerArguments["androidx.benchmark.output.enable"] = "true"
}

testBuildType = "release"
Expand Down Expand Up @@ -68,6 +65,8 @@ android {
}
}

afterEvaluate { configureFirebaseTestLabForMicroBenchmark() }

configurations {
all {
removeIncompatibleDependencies()
Expand All @@ -85,8 +84,13 @@ dependencies {
androidTestImplementation(Dependencies.junit)
androidTestImplementation(Dependencies.Kotlin.kotlinCoroutinesAndroid)
androidTestImplementation(Dependencies.truth)
androidTestImplementation(Dependencies.Androidx.workRuntimeKtx)
androidTestImplementation(Dependencies.AndroidxTest.workTestingRuntimeKtx)
androidTestImplementation(Dependencies.mockWebServer)
androidTestImplementation(Dependencies.Retrofit.coreRetrofit)

androidTestImplementation(project(":engine"))
androidTestImplementation(project(":knowledge"))
androidTestImplementation(project(":workflow"))
androidTestImplementation(project(":workflow-testing"))
}
3 changes: 3 additions & 0 deletions benchmark/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
-->
<application
android:debuggable="false"
android:usesCleartextTraffic="true"
tools:ignore="HardcodedDebugMode"
tools:replace="android:debuggable"
android:requestLegacyExternalStorage="true"
>
<profileable android:shell="true" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class D_FhirJsonParserBenchmark {
fun parseLightFhirBundle() {
benchmarkRule.measureRepeated {
val jsonParser = runWithTimingDisabled {
var fhirContext = FhirContext.forCached(FhirVersionEnum.R4)
val fhirContext = FhirContext.forCached(FhirVersionEnum.R4)
fhirContext.newJsonParser()
}

Expand All @@ -60,16 +60,14 @@ class D_FhirJsonParserBenchmark {
fun parseLightFhirLibrary() {
benchmarkRule.measureRepeated {
val jsonParser = runWithTimingDisabled {
var fhirContext = FhirContext.forCached(FhirVersionEnum.R4)
val fhirContext = FhirContext.forCached(FhirVersionEnum.R4)
fhirContext.newJsonParser()
}

val library = runWithTimingDisabled { open("/immunity-check/ImmunityCheck.json") }

val libraryBundle = jsonParser.parseResource(library) as Bundle

val immunityCheckLibrary = libraryBundle.entry[0].resource as Library
val fhirHelpersLibrary = libraryBundle.entry[1].resource as Library
val immunityCheckJson = runWithTimingDisabled { open("/immunity-check/ImmunityCheck.json") }
val immunityCheckLibrary = jsonParser.parseResource(immunityCheckJson) as Library
val fhirHelpersJson = runWithTimingDisabled { open("/immunity-check/FhirHelpers.json") }
val fhirHelpersLibrary = jsonParser.parseResource(fhirHelpersJson) as Library

assertThat(immunityCheckLibrary.id).isEqualTo("Library/ImmunityCheck-1.0.0")
assertThat(immunityCheckLibrary.content[0].data.size).isEqualTo(575)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import ca.uhn.fhir.context.FhirVersionEnum
import com.google.common.truth.Truth.assertThat
import java.io.InputStream
import java.io.StringReader
import org.hl7.fhir.r4.model.Bundle
import org.hl7.fhir.r4.model.Library
import org.junit.Rule
import org.junit.Test
Expand All @@ -43,13 +42,12 @@ class E_ElmJsonLibraryLoaderBenchmark {
@Test
fun parseImmunityCheckCqlFromFhirLibrary() {
benchmarkRule.measureRepeated {
val libraryBundle = runWithTimingDisabled {
var fhirContext = FhirContext.forCached(FhirVersionEnum.R4)
val immunityCheckLibrary = runWithTimingDisabled {
val fhirContext = FhirContext.forCached(FhirVersionEnum.R4)
val jsonParser = fhirContext.newJsonParser()
jsonParser.parseResource(open("/immunity-check/ImmunityCheck.json")) as Bundle
jsonParser.parseResource(open("/immunity-check/ImmunityCheck.json")) as Library
}

val immunityCheckLibrary = libraryBundle.entry[0].resource as Library
val jsonLib = immunityCheckLibrary.content.first { it.contentType == "application/elm+json" }

val immunityCheckCqlLibrary = JsonCqlLibraryReader().read(StringReader(String(jsonLib.data)))
Expand All @@ -61,13 +59,12 @@ class E_ElmJsonLibraryLoaderBenchmark {
@Test
fun parseFhirHelpersCqlFromFhirLibrary() {
benchmarkRule.measureRepeated {
val libraryBundle = runWithTimingDisabled {
var fhirContext = FhirContext.forCached(FhirVersionEnum.R4)
val fhirHelpersLibrary = runWithTimingDisabled {
val fhirContext = FhirContext.forCached(FhirVersionEnum.R4)
val jsonParser = fhirContext.newJsonParser()
jsonParser.parseResource(open("/immunity-check/ImmunityCheck.json")) as Bundle
jsonParser.parseResource(open("/immunity-check/FhirHelpers.json")) as Library
}

val fhirHelpersLibrary = libraryBundle.entry[1].resource as Library
val jsonLib = fhirHelpersLibrary.content.first { it.contentType == "application/elm+json" }

val fhirHelpersCqlLibrary = JsonCqlLibraryReader().read(StringReader(String(jsonLib.data)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import ca.uhn.fhir.context.FhirContext
import ca.uhn.fhir.context.FhirVersionEnum
import com.google.android.fhir.FhirEngineConfiguration
import com.google.android.fhir.FhirEngineProvider
import com.google.common.truth.Truth.assertThat
import java.io.InputStream
import kotlinx.coroutines.runBlocking
import org.hl7.fhir.r4.model.Bundle
import org.hl7.fhir.r4.model.ResourceType
import org.junit.AfterClass
import org.junit.BeforeClass
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -63,4 +66,18 @@ class F_EngineDatabaseBenchmark {
}
}
}

companion object {

@JvmStatic
@BeforeClass
fun oneTimeSetup() {
FhirEngineProvider.init(FhirEngineConfiguration(testMode = true))
}
@JvmStatic
@AfterClass
fun oneTimeTearDown() {
FhirEngineProvider.cleanup()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,26 @@

package com.google.android.fhir.benchmark

import android.content.Context
import androidx.benchmark.junit4.BenchmarkRule
import androidx.benchmark.junit4.measureRepeated
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import ca.uhn.fhir.context.FhirContext
import ca.uhn.fhir.context.FhirVersionEnum
import com.google.android.fhir.FhirEngineConfiguration
import com.google.android.fhir.FhirEngineProvider
import com.google.android.fhir.workflow.FhirOperator
import com.google.android.fhir.knowledge.KnowledgeManager
import com.google.android.fhir.workflow.FhirOperatorBuilder
import com.google.common.truth.Truth.assertThat
import java.io.File
import java.io.InputStream
import kotlinx.coroutines.runBlocking
import org.hl7.fhir.r4.model.Bundle
import org.hl7.fhir.r4.model.Library
import org.hl7.fhir.r4.model.Parameters
import org.junit.AfterClass
import org.junit.BeforeClass
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -48,20 +55,30 @@ class G_CqlEvaluatorBenchmark {
val fhirOperator = runWithTimingDisabled {
val fhirContext = FhirContext.forCached(FhirVersionEnum.R4)
val jsonParser = fhirContext.newJsonParser()
val context: Context = ApplicationProvider.getApplicationContext()

val patientImmunizationHistory =
jsonParser.parseResource(open("/immunity-check/ImmunizationHistory.json")) as Bundle
val fhirEngine = FhirEngineProvider.getInstance(ApplicationProvider.getApplicationContext())
val knowledgeManager = KnowledgeManager.createInMemory(context)
val lib = jsonParser.parseResource(open("/immunity-check/ImmunityCheck.json")) as Library

runBlocking {
for (entry in patientImmunizationHistory.entry) {
fhirEngine.create(entry.resource)
}
knowledgeManager.install(
File(context.filesDir, lib.name).apply {
writeText(jsonParser.encodeResourceToString(lib))
}
)
}

val lib = jsonParser.parseResource(open("/immunity-check/ImmunityCheck.json")) as Bundle

FhirOperator(fhirContext, fhirEngine).also { it.loadLibs(lib) }
FhirOperatorBuilder(context)
.withFhirContext(fhirContext)
.withFhirEngine(fhirEngine)
.withIgManager(knowledgeManager)
.build()
}

val results =
Expand All @@ -74,4 +91,18 @@ class G_CqlEvaluatorBenchmark {
assertThat(results.getParameterBool("CompletedImmunization")).isTrue()
}
}

companion object {

@JvmStatic
@BeforeClass
fun oneTimeSetup() {
FhirEngineProvider.init(FhirEngineConfiguration(testMode = true))
}
@JvmStatic
@AfterClass
fun oneTimeTearDown() {
FhirEngineProvider.cleanup()
}
}
}
Loading

0 comments on commit c60eeba

Please sign in to comment.