mirror of https://github.com/sbt/sbt.git
Remove return statements in UpdateReportPersistenceBenchmark
This commit is contained in:
parent
87d8ae3a6c
commit
324f863d60
|
|
@ -31,19 +31,19 @@ final case class BenchmarkResult(
|
||||||
|
|
||||||
object UpdateReportPersistenceBenchmark:
|
object UpdateReportPersistenceBenchmark:
|
||||||
|
|
||||||
@SuppressWarnings(Array("scalafix:DisableSyntax"))
|
|
||||||
def run(
|
def run(
|
||||||
iterations: Int = 500,
|
iterations: Int = 500,
|
||||||
configs: Seq[String] = Seq("compile", "test"),
|
configs: Seq[String] = Seq("compile", "test"),
|
||||||
modulesPerConfig: Int = 50,
|
modulesPerConfig: Int = 50,
|
||||||
warmupIterations: Int = 10
|
warmupIterations: Int = 10
|
||||||
): Either[String, BenchmarkResult] =
|
): Either[String, BenchmarkResult] =
|
||||||
if iterations <= 0 then return Left("iterations must be positive")
|
for {
|
||||||
if configs.isEmpty then return Left("configs must be non-empty")
|
_ <- Either.cond(iterations > 0, (), "iterations must be positive")
|
||||||
if modulesPerConfig <= 0 then return Left("modulesPerConfig must be positive")
|
_ <- Either.cond(configs.nonEmpty, (), "configs must be non-empty")
|
||||||
if warmupIterations < 0 then return Left("warmupIterations must be non-negative")
|
_ <- Either.cond(modulesPerConfig > 0, (), "modulesPerConfig must be positive")
|
||||||
|
_ <- Either.cond(warmupIterations >= 0, (), "warmupIterations must be non-negative")
|
||||||
val baseDir = IO.createTemporaryDirectory
|
baseDir = IO.createTemporaryDirectory
|
||||||
|
result <-
|
||||||
try
|
try
|
||||||
val report = buildSampleReport(baseDir, configs, modulesPerConfig)
|
val report = buildSampleReport(baseDir, configs, modulesPerConfig)
|
||||||
val fullStore = CacheStore(new File(baseDir, "full-format.json"))
|
val fullStore = CacheStore(new File(baseDir, "full-format.json"))
|
||||||
|
|
@ -85,6 +85,7 @@ object UpdateReportPersistenceBenchmark:
|
||||||
)
|
)
|
||||||
catch case e: Exception => Left(s"Benchmark failed: ${e.getMessage}")
|
catch case e: Exception => Left(s"Benchmark failed: ${e.getMessage}")
|
||||||
finally IO.delete(baseDir)
|
finally IO.delete(baseDir)
|
||||||
|
} yield result
|
||||||
|
|
||||||
def buildSampleReport(
|
def buildSampleReport(
|
||||||
baseDir: File,
|
baseDir: File,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue