Skip to content
Snippets Groups Projects
Commit 78584ece authored by Sören Henning's avatar Sören Henning
Browse files

Merge branch 'strategy-logs' into theodolite-kotlin

parents a1eb56c1 af745282
No related branches found
No related tags found
3 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
package theodolite.strategies.searchstrategy package theodolite.strategies.searchstrategy
import mu.KotlinLogging
import theodolite.execution.BenchmarkExecutor import theodolite.execution.BenchmarkExecutor
import theodolite.util.LoadDimension import theodolite.util.LoadDimension
import theodolite.util.Resource import theodolite.util.Resource
private val logger = KotlinLogging.logger {}
/** /**
* Binary-search-like implementation for determining the smallest suitable number of instances. * Binary-search-like implementation for determining the smallest suitable number of instances.
* *
...@@ -32,6 +35,8 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm ...@@ -32,6 +35,8 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm
} }
// special case: length == 1 or 2 // special case: length == 1 or 2
if (lower == upper) { if (lower == upper) {
val res = resources[lower]
logger.debug { "Running experiment with load $load and resources $res" }
if (this.benchmarkExecutor.runExperiment(load, resources[lower])) return lower if (this.benchmarkExecutor.runExperiment(load, resources[lower])) return lower
else { else {
if (lower + 1 == resources.size) return -1 if (lower + 1 == resources.size) return -1
...@@ -41,6 +46,8 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm ...@@ -41,6 +46,8 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm
// apply binary search for a list with // apply binary search for a list with
// length > 2 and adjust upper and lower depending on the result for `resources[mid]` // length > 2 and adjust upper and lower depending on the result for `resources[mid]`
val mid = (upper + lower) / 2 val mid = (upper + lower) / 2
val res = resources[mid]
logger.debug { "Running experiment with load $load and resources $res" }
if (this.benchmarkExecutor.runExperiment(load, resources[mid])) { if (this.benchmarkExecutor.runExperiment(load, resources[mid])) {
if (mid == lower) { if (mid == lower) {
return lower return lower
......
package theodolite.strategies.searchstrategy package theodolite.strategies.searchstrategy
import mu.KotlinLogging
import theodolite.execution.BenchmarkExecutor import theodolite.execution.BenchmarkExecutor
import theodolite.util.LoadDimension import theodolite.util.LoadDimension
import theodolite.util.Resource import theodolite.util.Resource
private val logger = KotlinLogging.logger {}
/** /**
* Linear-search-like implementation for determining the smallest suitable number of instances. * Linear-search-like implementation for determining the smallest suitable number of instances.
* *
...@@ -13,6 +16,8 @@ class LinearSearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm ...@@ -13,6 +16,8 @@ class LinearSearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm
override fun findSuitableResource(load: LoadDimension, resources: List<Resource>): Resource? { override fun findSuitableResource(load: LoadDimension, resources: List<Resource>): Resource? {
for (res in resources) { for (res in resources) {
logger.debug { "Running experiment with load $load and resources $res" }
if (this.benchmarkExecutor.runExperiment(load, res)) return res if (this.benchmarkExecutor.runExperiment(load, res)) return res
} }
return null return null
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment