Gitlab service upgraded. Please report any problems to dl_gitadmin@cs.lth.se

Commit 8ec970a2 authored by Noric Couderc's avatar Noric Couderc

Changed benchmark cleanup

Benchmarks used to clear() the datastructure on which they were running, but now
they only create a new data structure to use instead. The existing one will be
garbage collected.
parent 6f2bee79
......@@ -43,7 +43,7 @@ public class ApplicationBenchmark {
}
@Benchmark
public void ListApplicationBenchmark(BenchmarkState state) throws InvocationTargetException, IllegalAccessException {
public void ListApplicationBenchmark(BenchmarkState state) throws InvocationTargetException, IllegalAccessException, InstantiationException {
state.application.benchmark();
}
......
......@@ -67,7 +67,7 @@ public abstract class Application<T> {
return selected;
}
public void benchmark() throws InvocationTargetException, IllegalAccessException {
public void benchmark() throws InvocationTargetException, IllegalAccessException, InstantiationException {
for(int i = 0; i < applicationSize; ++i) {
methodsToCall[i].invoke(this);
}
......
......@@ -67,8 +67,8 @@ public class CollectionApplication<T extends Collection> extends Application<T>
}
@Override
public void benchmark() throws InvocationTargetException, IllegalAccessException {
public void benchmark() throws InvocationTargetException, IllegalAccessException, InstantiationException {
super.benchmark();
dataStructure.clear();
dataStructure = (T) dataStructure.getClass().newInstance();
}
}
......@@ -45,6 +45,4 @@ public class ListApplication extends CollectionApplication<List<Integer>> {
int b = generateIndex();
dataStructure.subList(Math.min(a, b), Math.max(a, b));
}
}
......@@ -44,8 +44,8 @@ public class MapApplication extends Application<Map<Integer, Integer>> {
public void runValues() { dataStructure.values(); }
@Override
public void benchmark() throws InvocationTargetException, IllegalAccessException {
public void benchmark() throws InvocationTargetException, IllegalAccessException, InstantiationException {
super.benchmark();
dataStructure.clear();
dataStructure = dataStructure.getClass().newInstance();
}
}
......@@ -20,7 +20,7 @@ import static se.lth.cs.UtilsKt.*;
public class ApplicationTest {
@Test
public void TestListApplication() {
public void TestListApplication() throws InstantiationException {
try {
for (int seed = 0; seed < 100; ++seed) {
ListApplication arrayListBench = new ListApplication(
......@@ -62,7 +62,7 @@ public class ApplicationTest {
}
@Test
public void TestSetApplication() {
public void TestSetApplication() throws InstantiationException {
try {
for (int seed = 0; seed < 100; ++seed) {
SetApplication hashSetBench = new SetApplication(seed, 10, new HashSet<>());
......@@ -88,7 +88,7 @@ public class ApplicationTest {
}
@Test
public void TestMapApplication() {
public void TestMapApplication() throws InstantiationException {
try {
for (int seed = 0; seed < 100; ++seed) {
MapApplication hashMapBench = new MapApplication(seed, 10, new HashMap<>());
......@@ -124,7 +124,7 @@ public class ApplicationTest {
}
@Test
public void TestListApplicationTime() throws InvocationTargetException, IllegalAccessException {
public void TestListApplicationTime() throws InvocationTargetException, IllegalAccessException, InstantiationException {
// Generate 20 applications, run them, get the best (running time, data structure)
for (int n = 0; n < 20; ++n) {
List<ListApplication> applications = new ArrayList<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment