-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBenchmark.java
More file actions
51 lines (43 loc) · 1.27 KB
/
Benchmark.java
File metadata and controls
51 lines (43 loc) · 1.27 KB
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
41
42
43
44
45
46
47
48
49
50
51
/**
* The benchmark contains a suite and an observer and is able to return the next problem.
*/
public class Benchmark {
private Suite suite;
private Observer observer;
/**
* Constructor
*/
public Benchmark(Suite suite, Observer observer) {
this.suite = suite;
this.observer = observer;
}
/**
* Function that returns the next problem in the suite. When it comes to the end of the suite,
* it returns null.
* @return the next problem in the suite or null when there is no next problem
* @throws Exception
*/
public Problem getNextProblem() throws Exception {
try {
long problemPointer = CocoJNI.cocoSuiteGetNextProblem(suite.getPointer(), observer.getPointer());
if (problemPointer == 0)
return null;
return new Problem(problemPointer);
} catch (Exception e) {
throw new Exception("Fetching of next problem failed.\n" + e.toString());
}
}
/**
* Finalizes the observer and suite. This method needs to be explicitly called in order to log
* the last results.
* @throws Exception
*/
public void finalizeBenchmark() throws Exception {
try {
observer.finalizeObserver();
suite.finalizeSuite();
} catch (Exception e) {
throw new Exception("Benchmark finalization failed.\n" + e.toString());
}
}
}