-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBenchmarkSet.scala
40 lines (33 loc) · 899 Bytes
/
BenchmarkSet.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package singularity.benchmarks
import edu.utexas.stac.Cost
import singularity._
import singularity.Runner.RunnerConfig
import scala.util.Random
object BenchmarkSet {
def measureCost[A](f: => A): Long = {
Cost.reset()
f
Cost.read()
}
def handleIllegalArgumentException[A](default: A)(f: => A): A = {
try{
f
}catch {
case _: IllegalArgumentException => default
}
}
def handleRuntimeException[A](default: A)(f: => A): A = {
try{
f
}catch {
case _: RuntimeException => default
}
}
def runExample(seed: Int, problemConfig: ProblemConfig, useGUI: Boolean, size: Int): Unit = {
val rand = new Random(seed)
Supernova.standardSupernova.fuzzProblem(
problemConfig,
RunnerConfig().copy(randomSeed = seed, ioId = seed, useGUI = useGUI),
ExecutionConfig(evalSizePolicy = FixedEvalSize(size)), rand)
}
}