diff --git a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/BinarySearch.kt b/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/BinarySearch.kt index e2af7b26a8a4e653b4a93e14285cf96d3589498b..6e56c3b36c6e2889e4714c890a424e4f6765386e 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/BinarySearch.kt +++ b/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/BinarySearch.kt @@ -42,8 +42,8 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm // special case: length == 1, so lower and upper bounds are the same if (lower == upper) { val res = resources[lower] - logger.info { "Running experiment with load '${load}' and resources '$res'" } - if (this.benchmarkExecutor.runExperiment(load, resources[lower])) return lower + logger.info { "Running experiment with load '$load' and resource '$res'" } + if (this.benchmarkExecutor.runExperiment(load, res)) return lower else { if (lower + 1 == resources.size) return -1 return lower + 1 @@ -53,8 +53,8 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm // length >= 2 and adjust upper and lower depending on the result for `resources[mid]` val mid = (upper + lower) / 2 val res = resources[mid] - logger.info { "Running experiment with load '${load}' and resources '$res'" } - if (this.benchmarkExecutor.runExperiment(load, resources[mid])) { + logger.info { "Running experiment with load '$load' and resource '$res'" } + if (this.benchmarkExecutor.runExperiment(load, res)) { // case length = 2 if (mid == lower) { return lower @@ -81,9 +81,9 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm } // length = 1, so lower and upper bounds are the same if (lower == upper) { - val res = loads[lower] - logger.info { "Running experiment with load '$resource' and resources '$res'" } - if (this.benchmarkExecutor.runExperiment(resource, loads[lower])) return lower + val load = loads[lower] + logger.info { "Running experiment with load '$load' and resource '$resource'" } + if (this.benchmarkExecutor.runExperiment(load, resource)) return lower else { if (lower + 1 == loads.size) return -1 return lower - 1 @@ -92,9 +92,9 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm // 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 + 1) / 2 //round to next int - val res = loads[mid] - logger.info { "Running experiment with load '$resource' and resources '$res'" } - if (this.benchmarkExecutor.runExperiment(resource, loads[mid])) { + val load = loads[mid] + logger.info { "Running experiment with load '$load' and resource '$resource'" } + if (this.benchmarkExecutor.runExperiment(load, resource)) { // length = 2, so since we round down mid is equal to lower if (mid == upper) { return upper diff --git a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/InitialGuessSearchStrategy.kt b/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/InitialGuessSearchStrategy.kt index 6b56e22a8f9c33c56fb3f8c36ae1673b9399b78d..447d810942be74f0cdbee865e3f0bb5d58e61603 100644 --- a/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/InitialGuessSearchStrategy.kt +++ b/theodolite/src/main/kotlin/theodolite/strategies/searchstrategy/InitialGuessSearchStrategy.kt @@ -93,7 +93,7 @@ class InitialGuessSearchStrategy( // If the first experiment passes, starting upwards linear search // otherwise starting downward linear search - if (!this.benchmarkExecutor.runExperiment(resource, lastMaxLoad)) { + if (!this.benchmarkExecutor.runExperiment(lastMaxLoad, resource)) { // downward search loadsToCheck = loads.subList(0, startIndex).reversed() @@ -101,7 +101,7 @@ class InitialGuessSearchStrategy( for (load in loadsToCheck) { logger.info { "Running experiment with resource '$resource' and load '$load'" } - if (this.benchmarkExecutor.runExperiment(resource, load)) { + if (this.benchmarkExecutor.runExperiment(load, resource)) { return load } } @@ -117,7 +117,7 @@ class InitialGuessSearchStrategy( var currentMax: Int = lastMaxLoad for (load in loadsToCheck) { logger.info { "Running experiment with resource '$resource' and load '$load'" } - if (this.benchmarkExecutor.runExperiment(resource, load)) { + if (this.benchmarkExecutor.runExperiment(load, resource)) { currentMax = load } }