Skip to content

Commit

Permalink
Merge pull request #1992 from GrzegorzBobryk/maintenance/performance-…
Browse files Browse the repository at this point in the history
…forEach-on-range

[Maintenance] performance `forEach` on range
  • Loading branch information
arnaudgiuliani authored Nov 15, 2024
2 parents 1fd7c85 + 5de2c7f commit 1ec7cfe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package org.koin.test

import kotlinx.coroutines.runBlocking
import org.koin.core.*
import org.koin.core.context.GlobalContext.startKoin
import org.koin.core.context.GlobalContext.stopKoin
import org.koin.core.context.waitKoinStart
import org.koin.core.logger.*
import org.koin.core.isAllStartedJobsDone
import org.koin.core.lazyModules
import org.koin.core.logger.EmptyLogger
import org.koin.core.logger.Level
import org.koin.core.logger.Logger
import org.koin.core.onKoinStarted
import org.koin.core.runOnKoinStarted
import org.koin.core.time.Timer
import org.koin.core.waitAllStartJobs
import org.koin.dsl.koinApplication
import org.koin.mp.KoinPlatform
import kotlin.test.Test
Expand All @@ -15,12 +21,16 @@ class PerfsTest {

@Test
fun perfModule400_module_perfs() {
(1..3).forEach { runPerfs() }
for (index in 1..3) {
runPerfs()
}
}

@Test
fun perfModule400_lazy_module_perfs() {
(1..3).forEach { runPerfs(isLazy = true) }
for (index in 1..3) {
runPerfs(isLazy = true)
}
}

private fun runPerfs(log: Logger = EmptyLogger(), isLazy: Boolean = false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ParameterStackTest {
)
}.koin

(1..10).forEach {
for (index in 1..10) {
koin.get<Simple.MyStringFactory> { parametersOf(KoinPlatformTools.generateId()) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DebugLogTest {
printLogger(Level.INFO)
}.koin

(1..10).forEach {
for (index in 1..10) {
measureDuration("with if") {
if (koin.logger.isAt(Level.DEBUG)) {
koin.logger.debug(message { "test me" })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//package org.koin.core.instance
//
//import org.junit.Assert.*
//import org.junit.Assert.assertEquals
//import org.junit.Assert.assertNotEquals
//import org.junit.Assert.fail
//import org.junit.Test
//import org.koin.core.error.InstanceCreationException
//import org.koin.core.logger.Level
Expand Down Expand Up @@ -123,7 +125,7 @@
// )
// }.koin
//
// (1..3).forEach {
// for (index in 1..3) {
// koin.get<Component>()
// }
// }
Expand Down

0 comments on commit 1ec7cfe

Please sign in to comment.