Skip to content
Snippets Groups Projects
Commit 79d68f42 authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

apply review (renaming, comments)

parent 4ea2b034
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus,!78Resolve "Implement Quarkus/Kotlin protype"
This commit is part of merge request !78. Comments created here will be created in the context of that merge request.
......@@ -48,7 +48,7 @@ class TheodoliteExecutor() {
// execute benchmarks for each load
for(load in config.loads) {
config.compositeStrategy.findSuitableResources(load, config.resources)
config.compositeStrategy.findSuitableResource(load, config.resources)
}
}
......
......@@ -7,7 +7,7 @@ import theodolite.util.Results
import java.lang.IllegalArgumentException
class BinarySearch(benchmarkExecutor: BenchmarkExecutor, results: Results) : SearchStrategy(benchmarkExecutor, results) {
override fun findSuitableResources(load: LoadDimension, resources: List<Resource>): Resource? {
override fun findSuitableResource(load: LoadDimension, resources: List<Resource>): Resource? {
val result = search(load, resources, 0, resources.size - 1)
if( result == -1 ) {
return null;
......@@ -19,6 +19,7 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor, results: Results) : Sea
if (lower > upper) {
throw IllegalArgumentException()
}
// special case: length == 1 or 2
if (lower == upper ) {
if (this.benchmarkExecutor.runExperiment(load, resources[lower])) return lower
else {
......@@ -26,6 +27,7 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor, results: Results) : Sea
return lower + 1
}
} else {
// apply binary search for a list with length > 2 and adjust upper and lower depending on the result for `resources[mid]`
val mid = (upper + lower) / 2
if (this.benchmarkExecutor.runExperiment(load, resources[mid])) {
if (mid == lower) {
......
......@@ -8,11 +8,11 @@ import theodolite.util.Results
class CompositeStrategy(benchmarkExecutor: BenchmarkExecutor, val searchStrategy: SearchStrategy, val restrictionStrategies: Set<RestrictionStrategy>, results: Results) : SearchStrategy(benchmarkExecutor, results) {
override fun findSuitableResources(load: LoadDimension, resources: List<Resource>): Resource? {
override fun findSuitableResource(load: LoadDimension, resources: List<Resource>): Resource? {
var restrictedResources = resources.toList()
for (strategy in this.restrictionStrategies) {
restrictedResources = restrictedResources.intersect(strategy.next(load, resources)).toList()
}
return this.searchStrategy.findSuitableResources(load, restrictedResources)
return this.searchStrategy.findSuitableResource(load, restrictedResources)
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ import theodolite.util.Results
class LinearSearch(benchmarkExecutor: BenchmarkExecutor, results: Results) : SearchStrategy(benchmarkExecutor, results) {
override fun findSuitableResources(load: LoadDimension, resources: List<Resource>): Resource? {
override fun findSuitableResource(load: LoadDimension, resources: List<Resource>): Resource? {
for (res in resources) {
if (this.benchmarkExecutor.runExperiment(load, res)) return res
}
......
......@@ -6,5 +6,5 @@ import theodolite.util.Resource
import theodolite.util.Results
abstract class SearchStrategy(val benchmarkExecutor: BenchmarkExecutor, val results: Results) {
abstract fun findSuitableResources(load: LoadDimension, resources: List<Resource>): Resource?;
abstract fun findSuitableResource(load: LoadDimension, resources: List<Resource>): Resource?;
}
\ No newline at end of file
......@@ -40,7 +40,7 @@ class CompositeStrategyTest {
expected.add(null)
for(load in mockLoads) {
actual.add(strategy.findSuitableResources(load, mockResources))
actual.add(strategy.findSuitableResource(load, mockResources))
}
assertEquals(actual, expected)
......@@ -71,7 +71,7 @@ class CompositeStrategyTest {
expected.add(null)
for(load in mockLoads) {
actual.add(strategy.findSuitableResources(load, mockResources))
actual.add(strategy.findSuitableResource(load, mockResources))
}
assertEquals(actual, expected)
......@@ -101,7 +101,7 @@ class CompositeStrategyTest {
val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6,7).map{ x -> Resource(x)})
for(load in mockLoads) {
actual.add(strategy.findSuitableResources(load, mockResources))
actual.add(strategy.findSuitableResource(load, mockResources))
}
assertEquals(actual, expected)
......
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