-
Notifications
You must be signed in to change notification settings - Fork 0
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
9 changed files
with
533 additions
and
95 deletions.
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
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,9 @@ | ||
fun main() { | ||
(1..101).forEach { | ||
println(""" | ||
open val s$it: Service$it by lazy { | ||
DefaultService$it(s${it + 1}) | ||
} | ||
""".trimIndent()) | ||
} | ||
} |
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,104 @@ | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties | ||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | ||
import com.fasterxml.jackson.module.kotlin.readValue | ||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
import java.time.Duration | ||
import java.util.Locale | ||
import kotlin.system.measureNanoTime | ||
|
||
val projects = listOf( | ||
"baseline", | ||
"bootique", | ||
"cayennedi", | ||
"dagger", | ||
"guice", | ||
// "helidon", | ||
"kodein", | ||
"koin", | ||
"koin-reflect", | ||
"komodo", | ||
"kotlin-lazy", | ||
// "micronaut", | ||
"owb", | ||
// "quarkus", | ||
"spring", | ||
// "spring-fu", | ||
// "spring-index", | ||
// "spring-scan", | ||
// "spring-scan-large", | ||
// "spring-xml", | ||
"springboot", | ||
// "springboot-index", | ||
) | ||
|
||
data class TestResult( | ||
val project: String, | ||
val fileSize: String, // MB | ||
val loc: Int, | ||
val execTime: Long // ms | ||
) | ||
|
||
val om = jacksonObjectMapper() | ||
|
||
fun main() { | ||
val jvm = listOf("jvm").map(::calculate).sortedBy { it.execTime }.toTable() | ||
val table = projects.map(::calculate).sortedBy { it.execTime }.toTable() | ||
val tableDeep = projects.map { "$it-deep" }.map(::calculate).sortedBy { it.execTime }.toTable() | ||
|
||
println(jvm) | ||
println(table) | ||
println(tableDeep) | ||
} | ||
|
||
fun calculate(prj: String): TestResult { | ||
val iterations = 50 | ||
|
||
val artifactPath = Paths.get("$prj/build/distributions/$prj.tar") | ||
val size = Files.size(artifactPath) | ||
|
||
val clocProc = ProcessBuilder() | ||
.command("/usr/local/bin/cloc", "--json", "/Users/mbp/dev/pet/di-comparison/$prj/src") | ||
.start() | ||
val clocText = clocProc.inputStream.reader().readText() | ||
val clocResult = om.readValue<ClocResult>(clocText) | ||
|
||
val nanos = measureNanoTime { | ||
(1..iterations).forEach { iter -> | ||
println("$prj-$iter") | ||
ProcessBuilder() | ||
.command("/Users/mbp/dev/pet/di-comparison/$prj/build/install/$prj/bin/$prj") | ||
.start() | ||
.waitFor() | ||
} | ||
} | ||
|
||
return TestResult( | ||
project = prj, | ||
fileSize = "%1$,.2f".format(Locale.US, size.toDouble() / 1024 / 1024), | ||
loc = clocResult.sum.code, | ||
execTime = Duration.ofNanos(nanos / iterations).toMillis() | ||
) | ||
} | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
data class ClocResult( | ||
@JsonProperty("SUM") | ||
val sum: ClocSumResult | ||
) | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
data class ClocSumResult( | ||
val code: Int | ||
) | ||
|
||
fun List<TestResult>.toTable(): String { | ||
return buildString { | ||
appendLine("|DI|Jar w/Deps Size, Mb|:arrow_down: Exec time, ms|LoC|") | ||
appendLine("|----|----|----|----|") | ||
this@toTable.forEach { result -> | ||
appendLine("|${result.project}|${result.fileSize}|${result.execTime}|${result.loc}|") | ||
} | ||
} | ||
} |
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,20 @@ | ||
plugins { | ||
kotlin("jvm").version("1.4.31") | ||
application | ||
} | ||
|
||
application { | ||
mainClass.set("io.heapy.klazy.MainKt") | ||
} | ||
|
||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach { | ||
kotlinOptions.jvmTarget = "11" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation(project(":common-deep")) | ||
} |
Oops, something went wrong.