Skip to content

Commit

Permalink
FHIR Sync worker benchmarking (#1997)
Browse files Browse the repository at this point in the history
* FHIR Sync worker benchmarking

* spotless corrections applied

* addressing review comments
  • Loading branch information
anchita-g committed May 15, 2023
1 parent 49290c5 commit ab256e0
Show file tree
Hide file tree
Showing 6 changed files with 434 additions and 16 deletions.
3 changes: 3 additions & 0 deletions benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ dependencies {
androidTestImplementation(Dependencies.junit)
androidTestImplementation(Dependencies.Kotlin.kotlinCoroutinesAndroid)
androidTestImplementation(Dependencies.truth)
androidTestImplementation(Dependencies.Androidx.workRuntimeKtx)
androidTestImplementation(Dependencies.AndroidxTest.workTestingRuntimeKtx)
androidTestImplementation(Dependencies.mockWebServer)

androidTestImplementation(project(":engine"))
androidTestImplementation(project(":knowledge"))
Expand Down
2 changes: 2 additions & 0 deletions benchmark/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
-->
<application
android:debuggable="false"
android:usesCleartextTraffic="true"
tools:ignore="HardcodedDebugMode"
tools:replace="android:debuggable"
>
<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 @@ -64,12 +64,10 @@ class D_FhirJsonParserBenchmark {
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
Loading

0 comments on commit ab256e0

Please sign in to comment.