-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
189 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...t/java/org/smartregister/fhircore/engine/performance/DefaultRepositoryPerformanceTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.smartregister.fhircore.engine.performance | ||
|
||
import androidx.benchmark.junit4.BenchmarkRule | ||
import androidx.benchmark.junit4.measureRepeated | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import dagger.hilt.android.testing.HiltAndroidRule | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.smartregister.fhircore.engine.data.local.DefaultRepository | ||
import org.smartregister.fhircore.engine.data.local.register.RegisterRepository | ||
import javax.inject.Inject | ||
|
||
|
||
/** | ||
* Created by Ephraim Kigamba - [email protected] on 11-07-2023. | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
@HiltAndroidTest | ||
class DefaultRepositoryPerformanceTests { | ||
|
||
@get:Rule | ||
val benchmarkRule = BenchmarkRule() | ||
|
||
@Inject lateinit var defaultRepository: DefaultRepository | ||
@Inject lateinit var registerRepository: RegisterRepository | ||
|
||
|
||
@get:Rule val hiltRule = HiltAndroidRule(this) | ||
|
||
@Test | ||
fun benchmarkSomeWork() { | ||
benchmarkRule.measureRepeated { | ||
registerRepository.retrieveRegisterConfiguration("householdRegister", hashMapOf()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
Copyright 2019 The Android Open Source Project | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<!-- [START benchmark_manifest] --> | ||
|
||
<!-- Requesting legacy storage is needed to be able to write to additionalTestOutputDir on API 29 --> | ||
<application android:requestLegacyExternalStorage="true"> | ||
|
||
<profileable android:shell="true" /> | ||
|
||
</application> | ||
<!-- [END benchmark_manifest] --> | ||
</manifest> |
30 changes: 30 additions & 0 deletions
30
...quest/src/androidTest/java/org/smartregister/fhircore/quest/config/ConfigServiceModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2021-2023 Ona Systems, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.smartregister.fhircore.quest.di.config | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import org.smartregister.fhircore.engine.configuration.app.ConfigService | ||
import org.smartregister.fhircore.quest.QuestConfigService | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
abstract class ConfigServiceModule { | ||
@Binds abstract fun provideConfigService(questConfigService: QuestConfigService): ConfigService | ||
} |
80 changes: 80 additions & 0 deletions
80
...st/java/org/smartregister/fhircore/quest/performance/DefaultRepositoryPerformanceTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package org.smartregister.fhircore.quest.performance | ||
|
||
import androidx.benchmark.junit4.BenchmarkRule | ||
import androidx.benchmark.junit4.measureRepeated | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import dagger.hilt.android.testing.HiltAndroidRule | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.smartregister.fhircore.engine.R | ||
import org.smartregister.fhircore.engine.data.local.DefaultRepository | ||
import org.smartregister.fhircore.engine.data.local.register.RegisterRepository | ||
import org.smartregister.fhircore.engine.util.SharedPreferenceKey | ||
import org.smartregister.fhircore.engine.util.extension.getActivity | ||
import org.smartregister.fhircore.engine.util.extension.launchActivityWithNoBackStackHistory | ||
import org.smartregister.fhircore.quest.QuestTestRunner | ||
import org.smartregister.fhircore.quest.ui.login.LoginActivity | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
|
||
/** | ||
* Created by Ephraim Kigamba - [email protected] on 11-07-2023. | ||
*/ | ||
//@RunWith(AndroidJUnit4::class) | ||
@HiltAndroidTest | ||
class DefaultRepositoryPerformanceTests { | ||
|
||
@get:Rule | ||
val benchmarkRule = BenchmarkRule() | ||
|
||
@Inject lateinit var defaultRepository: DefaultRepository | ||
@Inject lateinit var registerRepository: RegisterRepository | ||
|
||
|
||
@get:Rule val hiltRule = HiltAndroidRule(this) | ||
|
||
@Before | ||
fun setUp() { | ||
hiltRule.inject() | ||
|
||
if (InstrumentationRegistry.getInstrumentation().context.externalCacheDir == null ) { | ||
Timber.e("Instrumentation registry is null") | ||
} else { | ||
Timber.e("Instrumentation registry is NOT NULL") | ||
} | ||
|
||
runBlocking { | ||
defaultRepository.configurationRegistry.loadConfigurations("app/debug", InstrumentationRegistry.getInstrumentation().targetContext) { loadConfigSuccessful -> | ||
|
||
/*if (loadConfigSuccessful) { | ||
sharedPreferencesHelper.write(SharedPreferenceKey.APP_ID.name, thisAppId) | ||
context.getActivity()?.launchActivityWithNoBackStackHistory<LoginActivity>() | ||
} else { | ||
_error.postValue(context.getString(R.string.application_not_supported, appId.value)) | ||
}*/ | ||
} | ||
} | ||
|
||
// Plant Timber tree to print in the console | ||
|
||
Timber.plant(Timber.DebugTree()) | ||
} | ||
|
||
@Test | ||
fun benchmarkSomeWork() { | ||
benchmarkRule.measureRepeated { | ||
//registerRepository.retrieveRegisterConfiguration("householdRegister", hashMapOf()) | ||
|
||
runBlocking { | ||
val repoData = registerRepository.loadRegisterData(0, "householdRegister") | ||
System.out.println("Records fetched ${repoData.size}") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters