Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies updated #9

Merged
merged 1 commit into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
This project aims to measure the performance of several Dependency Injection frameworks (or Service Locators) in different devices.

## Libraries tested
- [Koin](https://insert-koin.io/) - 2.0.0-alpha-3
- [Kodein](http://kodein.org/Kodein-DI/) - 5.3.0
- [Dagger 2](https://google.github.io/dagger/) - 2.16
- [Katana](https://github.com/rewe-digital-incubator/katana/) - 1.2.2
- [Koin](https://insert-koin.io/) - 2.0.1
- [Kodein](http://kodein.org/Kodein-DI/) - 6.3.3
- [Dagger 2](https://google.github.io/dagger/) - 2.24
- [Katana](https://github.com/rewe-digital-incubator/katana/) - 1.7.1

## The test
The test data are classes with dependencies in a structure similar to Fibonacci sequence, to simulate multiple levels of transitive dependencies.
Expand All @@ -28,9 +28,10 @@ Results can be quite different between different devices, so here are some resul
- [OnePlus One](#oneplus-one)
- [OnePlus 5](#oneplus-5)
- [Nexus 6](#nexus-6)
- [OnePlus 5T](#oneplus-5t) (dependencies updated)

### Samsung Galaxy J5
samsung j5nlte with Android 6.0.1
Samsung j5nlte with Android 6.0.1

Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
--- | ---:| ---:| ---:| ---:
Expand All @@ -41,7 +42,7 @@ Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
**Dagger** | 0.02 ms | 0.02 ms | 0.27 ms | 0.23 ms

### Samsung Galaxy S8
samsung dreamlte with Android 8.0.0
Samsung dreamlte with Android 8.0.0

Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
--- | ---:| ---:| ---:| ---:
Expand All @@ -63,7 +64,7 @@ Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
**Dagger** | 0.00 ms | 0.00 ms | 0.03 ms | 0.02 ms

### Xiaomi MI A1
xiaomi tissot_sprout with Android 8.1.0
Xiaomi tissot_sprout with Android 8.1.0

Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
--- | ---:| ---:| ---:| ---:
Expand All @@ -74,7 +75,7 @@ Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
**Dagger** | 0.02 ms | 0.02 ms | 0.28 ms | 0.21 ms

### OnePlus One
oneplus A0001 with Android 5.0.2
OnePlus A0001 with Android 5.0.2

Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
--- | ---:| ---:| ---:| ---:
Expand All @@ -96,7 +97,7 @@ Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
**Dagger** | 0.00 ms | 0.00 ms | 0.04 ms | 0.02 ms

### Nexus 6
google shamu with Android 7.1.1
Google shamu with Android 7.1.1

Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
--- | ---:| ---:| ---:| ---:
Expand All @@ -105,3 +106,14 @@ Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
**Katana** | 1.23 ms | 1.16 ms | 0.31 ms | 0.27 ms
**Custom** | 0.29 ms | 0.29 ms | 0.20 ms | 0.31 ms
**Dagger** | 0.03 ms | 0.03 ms | 0.22 ms | 0.15 ms

### OnePlus 5T
OnePlus OnePlus5T with Android 9.0

Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
--- | ---:| ---:| ---:| ---:
**Koin** | 0.45 ms | 0.47 ms | 0.06 ms | 0.05 ms
**Kodein** | 5.21 ms | 5.30 ms | 0.09 ms | 0.09 ms
**Katana** | 0.34 ms | 0.37 ms | 0.04 ms | 0.04 ms
**Custom** | 0.08 ms | 0.08 ms | 0.03 ms | 0.03 ms
**Dagger** | 0.00 ms | 0.00 ms | 0.03 ms | 0.04 ms
29 changes: 20 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,38 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

// Fix for "Cannot inline bytecode built with JVM target 1.8 into bytecode
// that is being built with JVM target 1.6"
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation "androidx.core:core-ktx:1.2.0-alpha01"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1"
implementation "androidx.core:core-ktx:1.2.0-alpha04"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.2"

// Koin
implementation "org.koin:koin-android:2.0.0-alpha-3"
implementation "org.koin:koin-android:2.0.1"

// Kodein
implementation 'org.kodein.di:kodein-di-erased-jvm:5.3.0'
implementation 'org.kodein.di:kodein-di-erased-jvm:6.3.3'

// Dagger
implementation 'com.google.dagger:dagger:2.16'
kapt 'com.google.dagger:dagger-compiler:2.16'
implementation 'com.google.dagger:dagger:2.24'
kapt 'com.google.dagger:dagger-compiler:2.24'

// Katana
implementation 'com.github.rewe-digital-incubator.katana:katana-android:1.2.2'
implementation 'org.rewedigital.katana:katana-android:1.7.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.sloydev.dependencyinjectionperformance.dagger2.JavaDaggerComponent
import com.sloydev.dependencyinjectionperformance.dagger2.KotlinDaggerComponent
import com.sloydev.dependencyinjectionperformance.katana.katanaJavaModule
import com.sloydev.dependencyinjectionperformance.katana.katanaKotlinModule
import com.sloydev.dependencyinjectionperformance.kodein.kodeinKotlinModule
import com.sloydev.dependencyinjectionperformance.kodein.kodeinJavaModule
import com.sloydev.dependencyinjectionperformance.koin.koinJavaModule
import com.sloydev.dependencyinjectionperformance.koin.koinKotlinModule
import org.kodein.di.Kodein
Expand All @@ -23,7 +25,6 @@ import org.rewedigital.katana.Component
import org.rewedigital.katana.Katana
import org.rewedigital.katana.android.environment.AndroidEnvironmentContext
import org.rewedigital.katana.android.environment.AndroidEnvironmentContext.Profile.SPEED
import org.rewedigital.katana.createComponent
import javax.inject.Inject

class InjectionTest : KoinComponent {
Expand All @@ -45,7 +46,17 @@ class InjectionTest : KoinComponent {
return results
}


private fun reportMarkdown(results: List<LibraryResult>) {
log("Done!")
log(" ")
log("${Build.BRAND} ${Build.DEVICE} with Android ${Build.VERSION.RELEASE}")
log(" ")
log("Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java")
log("--- | ---:| ---:| ---:| ---:")
results.forEach {
log("**${it.injectorName}** | ${it[Variant.KOTLIN].startupTime.median().format()} | ${it[Variant.JAVA].startupTime.median().format()} | ${it[Variant.KOTLIN].injectionTime.median().format()} | ${it[Variant.JAVA].injectionTime.median().format()}")
}
}

private fun runTest(
setup: () -> Unit,
Expand Down Expand Up @@ -93,8 +104,8 @@ class InjectionTest : KoinComponent {
test = { kodein.direct.instance<Fib8>() }
),
Variant.JAVA to runTest(
setup = { kodein = Kodein { import(kodeinKotlinModule) } },
test = { kodein.direct.instance<Fib8>() }
setup = { kodein = Kodein { import(kodeinJavaModule) } },
test = { kodein.direct.instance<FibonacciJava.Fib8>() }
)
))
}
Expand All @@ -105,11 +116,11 @@ class InjectionTest : KoinComponent {
lateinit var component: Component
return LibraryResult("Katana", mapOf(
Variant.KOTLIN to runTest(
setup = { component = createComponent(modules = listOf(katanaKotlinModule)) },
setup = { component = Component(modules = listOf(katanaKotlinModule)) },
test = { component.injectNow<Fib8>() }
),
Variant.JAVA to runTest(
setup = { component = createComponent(modules = listOf(katanaJavaModule)) },
setup = { component = Component(modules = listOf(katanaJavaModule)) },
test = { component.injectNow<FibonacciJava.Fib8>() }
)
))
Expand Down
Loading