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

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

Created benchmarks for sets and maps

The benchmarks run generated applications for sets and maps.
parent 2e2b67ce
......@@ -2,20 +2,17 @@ package se.lth.cs;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import se.lth.cs.ApplicationGeneration.ListApplicationGenerator;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class ApplicationBenchmark {
public class ListApplicationBenchmark {
@State(Scope.Thread)
public static class BenchmarkState {
public static class ListBenchmarkState {
@Param({"0", "1", "2", "3"})
public int seed;
......@@ -41,7 +38,7 @@ public class ApplicationBenchmark {
}
@Benchmark
public void ListApplicationBenchmark(BenchmarkState state, Blackhole blackhole) throws InvocationTargetException, IllegalAccessException, InstantiationException {
public void ListApplicationBenchmark(ListBenchmarkState state, Blackhole blackhole) throws InvocationTargetException, IllegalAccessException, InstantiationException {
blackhole.consume(state.currentApplication.benchmark());
}
......@@ -70,7 +67,7 @@ public class ApplicationBenchmark {
// .collect(Collectors.toList());
// Options opt = new OptionsBuilder()
// .include(ApplicationBenchmark.class.getSimpleName())
// .include(ListApplicationBenchmark.class.getSimpleName())
// .param("seed", seeds.toArray(new String[0]))
// .param("applicationSize", applicationSizes.toArray(new String[0]))
// .build();
......
package se.lth.cs;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
public class MapApplicationBenchmark {
@State(Scope.Thread)
public static class MapBenchmarkState {
@Param({"0", "1", "2", "3"})
public int seed;
@Param({"100", "1000"})
public int applicationSize;
@Param({"HashMap", "TreeMap", "IdentityHashMap", "LinkedHashMap", "WeakHashMap"})
public String datastructureName;
public Application currentApplication;
@Setup(Level.Trial)
public void doSetup() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
Map<Integer, Integer> datastructure = (Map<Integer, Integer>) Class.forName("java.util." + datastructureName).newInstance();
currentApplication = new MapApplication(seed, applicationSize, datastructure);
}
}
@Benchmark
public void MapApplicationBenchmark(MapBenchmarkState state, Blackhole blackhole) throws InvocationTargetException, IllegalAccessException, InstantiationException {
blackhole.consume(state.currentApplication.benchmark());
}
}
package se.lth.cs;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
public class SetApplicationBenchmark {
@State(Scope.Thread)
public static class SetBenchmarkState {
@Param({"0", "1", "2", "3"})
public int seed;
@Param({"100", "1000"})
public int applicationSize;
@Param({"HashSet", "TreeSet", "LinkedHashSet"})
public String datastructureName;
public Application currentApplication;
@Setup(Level.Trial)
public void doSetup() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
Set<Integer> datastructure = (Set<Integer>) Class.forName("java.util." + datastructureName).newInstance();
currentApplication = new SetApplication(seed, applicationSize, datastructure);
}
}
@Benchmark
public void SetApplicationBenchmark(SetBenchmarkState state, Blackhole blackhole) throws InvocationTargetException, IllegalAccessException, InstantiationException {
blackhole.consume(state.currentApplication.benchmark());
}
}
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