Skip to content
Snippets Groups Projects
Commit 7f4ff7b3 authored by Marcel Samir Becker's avatar Marcel Samir Becker
Browse files

Fixed Binary Search Capacity Metric

parent df6d1ebd
No related branches found
No related tags found
1 merge request!215Redesign Strategy, Load, and Resources data types
......@@ -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
......
......@@ -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
}
}
......
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