Skip to content

Commit 89ff9ec

Browse files
- Gradle and Kotlin version updated. (#9)
- Dependencies updated. - reportMarkdown method added again. - KodeinTest modified (it wasn't using kodeinJavaModule). - KatanaTest modified, deprecated function replaced. - KatanaJava and KatanaKotlin modules refactored. - Readme updated with results for One Plus 5T.
1 parent 75dde08 commit 89ff9ec

File tree

9 files changed

+974
-941
lines changed

9 files changed

+974
-941
lines changed

README.md

+21-9
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
This project aims to measure the performance of several Dependency Injection frameworks (or Service Locators) in different devices.
44

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

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

3233
### Samsung Galaxy J5
33-
samsung j5nlte with Android 6.0.1
34+
Samsung j5nlte with Android 6.0.1
3435

3536
Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
3637
--- | ---:| ---:| ---:| ---:
@@ -41,7 +42,7 @@ Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
4142
**Dagger** | 0.02 ms | 0.02 ms | 0.27 ms | 0.23 ms
4243

4344
### Samsung Galaxy S8
44-
samsung dreamlte with Android 8.0.0
45+
Samsung dreamlte with Android 8.0.0
4546

4647
Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
4748
--- | ---:| ---:| ---:| ---:
@@ -63,7 +64,7 @@ Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
6364
**Dagger** | 0.00 ms | 0.00 ms | 0.03 ms | 0.02 ms
6465

6566
### Xiaomi MI A1
66-
xiaomi tissot_sprout with Android 8.1.0
67+
Xiaomi tissot_sprout with Android 8.1.0
6768

6869
Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
6970
--- | ---:| ---:| ---:| ---:
@@ -74,7 +75,7 @@ Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
7475
**Dagger** | 0.02 ms | 0.02 ms | 0.28 ms | 0.21 ms
7576

7677
### OnePlus One
77-
oneplus A0001 with Android 5.0.2
78+
OnePlus A0001 with Android 5.0.2
7879

7980
Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
8081
--- | ---:| ---:| ---:| ---:
@@ -96,7 +97,7 @@ Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
9697
**Dagger** | 0.00 ms | 0.00 ms | 0.04 ms | 0.02 ms
9798

9899
### Nexus 6
99-
google shamu with Android 7.1.1
100+
Google shamu with Android 7.1.1
100101

101102
Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
102103
--- | ---:| ---:| ---:| ---:
@@ -105,3 +106,14 @@ Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
105106
**Katana** | 1.23 ms | 1.16 ms | 0.31 ms | 0.27 ms
106107
**Custom** | 0.29 ms | 0.29 ms | 0.20 ms | 0.31 ms
107108
**Dagger** | 0.03 ms | 0.03 ms | 0.22 ms | 0.15 ms
109+
110+
### OnePlus 5T
111+
OnePlus OnePlus5T with Android 9.0
112+
113+
Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java
114+
--- | ---:| ---:| ---:| ---:
115+
**Koin** | 0.45 ms | 0.47 ms | 0.06 ms | 0.05 ms
116+
**Kodein** | 5.21 ms | 5.30 ms | 0.09 ms | 0.09 ms
117+
**Katana** | 0.34 ms | 0.37 ms | 0.04 ms | 0.04 ms
118+
**Custom** | 0.08 ms | 0.08 ms | 0.03 ms | 0.03 ms
119+
**Dagger** | 0.00 ms | 0.00 ms | 0.03 ms | 0.04 ms

app/build.gradle

+20-9
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,38 @@ android {
1919
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2020
}
2121
}
22+
23+
// Fix for "Cannot inline bytecode built with JVM target 1.8 into bytecode
24+
// that is being built with JVM target 1.6"
25+
compileOptions {
26+
sourceCompatibility = 1.8
27+
targetCompatibility = 1.8
28+
}
29+
30+
kotlinOptions {
31+
jvmTarget = "1.8"
32+
}
2233
}
2334

2435
dependencies {
2536
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
26-
implementation 'androidx.appcompat:appcompat:1.0.2'
37+
implementation 'androidx.appcompat:appcompat:1.1.0'
2738
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
2839
implementation 'com.google.android.material:material:1.0.0'
29-
implementation "androidx.core:core-ktx:1.2.0-alpha01"
30-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1"
31-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1"
40+
implementation "androidx.core:core-ktx:1.2.0-alpha04"
41+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.2"
42+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.2"
3243

3344
// Koin
34-
implementation "org.koin:koin-android:2.0.0-alpha-3"
45+
implementation "org.koin:koin-android:2.0.1"
3546

3647
// Kodein
37-
implementation 'org.kodein.di:kodein-di-erased-jvm:5.3.0'
48+
implementation 'org.kodein.di:kodein-di-erased-jvm:6.3.3'
3849

3950
// Dagger
40-
implementation 'com.google.dagger:dagger:2.16'
41-
kapt 'com.google.dagger:dagger-compiler:2.16'
51+
implementation 'com.google.dagger:dagger:2.24'
52+
kapt 'com.google.dagger:dagger-compiler:2.24'
4253

4354
// Katana
44-
implementation 'com.github.rewe-digital-incubator.katana:katana-android:1.2.2'
55+
implementation 'org.rewedigital.katana:katana-android:1.7.1'
4556
}

app/src/main/java/com/sloydev/dependencyinjectionperformance/InjectionTest.kt

+17-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import com.sloydev.dependencyinjectionperformance.dagger2.JavaDaggerComponent
1010
import com.sloydev.dependencyinjectionperformance.dagger2.KotlinDaggerComponent
1111
import com.sloydev.dependencyinjectionperformance.katana.katanaJavaModule
1212
import com.sloydev.dependencyinjectionperformance.katana.katanaKotlinModule
13+
import com.sloydev.dependencyinjectionperformance.kodein.kodeinKotlinModule
14+
import com.sloydev.dependencyinjectionperformance.kodein.kodeinJavaModule
1315
import com.sloydev.dependencyinjectionperformance.koin.koinJavaModule
1416
import com.sloydev.dependencyinjectionperformance.koin.koinKotlinModule
1517
import org.kodein.di.Kodein
@@ -23,7 +25,6 @@ import org.rewedigital.katana.Component
2325
import org.rewedigital.katana.Katana
2426
import org.rewedigital.katana.android.environment.AndroidEnvironmentContext
2527
import org.rewedigital.katana.android.environment.AndroidEnvironmentContext.Profile.SPEED
26-
import org.rewedigital.katana.createComponent
2728
import javax.inject.Inject
2829

2930
class InjectionTest : KoinComponent {
@@ -45,7 +46,17 @@ class InjectionTest : KoinComponent {
4546
return results
4647
}
4748

48-
49+
private fun reportMarkdown(results: List<LibraryResult>) {
50+
log("Done!")
51+
log(" ")
52+
log("${Build.BRAND} ${Build.DEVICE} with Android ${Build.VERSION.RELEASE}")
53+
log(" ")
54+
log("Library | Setup Kotlin | Setup Java | Inject Kotlin | Inject Java")
55+
log("--- | ---:| ---:| ---:| ---:")
56+
results.forEach {
57+
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()}")
58+
}
59+
}
4960

5061
private fun runTest(
5162
setup: () -> Unit,
@@ -93,8 +104,8 @@ class InjectionTest : KoinComponent {
93104
test = { kodein.direct.instance<Fib8>() }
94105
),
95106
Variant.JAVA to runTest(
96-
setup = { kodein = Kodein { import(kodeinKotlinModule) } },
97-
test = { kodein.direct.instance<Fib8>() }
107+
setup = { kodein = Kodein { import(kodeinJavaModule) } },
108+
test = { kodein.direct.instance<FibonacciJava.Fib8>() }
98109
)
99110
))
100111
}
@@ -105,11 +116,11 @@ class InjectionTest : KoinComponent {
105116
lateinit var component: Component
106117
return LibraryResult("Katana", mapOf(
107118
Variant.KOTLIN to runTest(
108-
setup = { component = createComponent(modules = listOf(katanaKotlinModule)) },
119+
setup = { component = Component(modules = listOf(katanaKotlinModule)) },
109120
test = { component.injectNow<Fib8>() }
110121
),
111122
Variant.JAVA to runTest(
112-
setup = { component = createComponent(modules = listOf(katanaJavaModule)) },
123+
setup = { component = Component(modules = listOf(katanaJavaModule)) },
113124
test = { component.injectNow<FibonacciJava.Fib8>() }
114125
)
115126
))

0 commit comments

Comments
 (0)