From c748aec660bf117188516cc3bf13a069827228b6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Genevi=C3=A8ve=20Bastien?= Date: Thu, 20 Oct 2016 16:43:01 -0400 Subject: [PATCH] segStore: allow benchmarks to specify the size of the store MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This will allow other benchmarks to extend this class but with a different number of segments Change-Id: I328c38831cbbb9bb23375d4367aec7a07dc5101e Signed-off-by: Geneviève Bastien Reviewed-on: https://git.eclipse.org/r/83636 Reviewed-by: Hudson CI --- .../tests/store/SegmentStoreBenchmark.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/statesystem/org.eclipse.tracecompass.segmentstore.core.tests/perf/org/eclipse/tracecompass/analysis/timing/core/tests/store/SegmentStoreBenchmark.java b/statesystem/org.eclipse.tracecompass.segmentstore.core.tests/perf/org/eclipse/tracecompass/analysis/timing/core/tests/store/SegmentStoreBenchmark.java index 1dc8c8aff3..246e8f0bf3 100644 --- a/statesystem/org.eclipse.tracecompass.segmentstore.core.tests/perf/org/eclipse/tracecompass/analysis/timing/core/tests/store/SegmentStoreBenchmark.java +++ b/statesystem/org.eclipse.tracecompass.segmentstore.core.tests/perf/org/eclipse/tracecompass/analysis/timing/core/tests/store/SegmentStoreBenchmark.java @@ -76,6 +76,15 @@ public class SegmentStoreBenchmark { fName = name; } + /** + * Get the number of segments to add to the segment store + * + * @return The number of segments to add to the segment store + */ + protected long getSegmentStoreSize() { + return 1000000; + } + /** * Add elements in order */ @@ -265,10 +274,11 @@ public class SegmentStoreBenchmark { outputResults(duration, method); } - private static long populate(int size, int[] fuzz, ISegmentStore<@NonNull ISegment> store) { + + private long populate(int size, int[] fuzz, ISegmentStore<@NonNull ISegment> store) { store.clear(); long start = System.nanoTime(); - populate(size, fuzz, store, 1000000); + populate(size, fuzz, store, getSegmentStoreSize()); long end = System.nanoTime(); return end - start; } @@ -279,7 +289,7 @@ public class SegmentStoreBenchmark { outputResults(duration, method); } - private static long addAndIterate(int size, int[] fuzz, ISegmentStore<@NonNull ISegment> store) { + private long addAndIterate(int size, int[] fuzz, ISegmentStore<@NonNull ISegment> store) { long start = System.nanoTime(); populate(size, fuzz, store); iterate(store); @@ -325,9 +335,9 @@ public class SegmentStoreBenchmark { return shutupCompilerWarnings; } - private static void populate(int size, int[] fuzz, ISegmentStore<@NonNull ISegment> store, int count) { + private static void populate(int size, int[] fuzz, ISegmentStore<@NonNull ISegment> store, long count) { for (int i = 0; i < count; i++) { - long start = i + fuzz[i % size]; + long start = (long) i + fuzz[i % size]; store.add(new BasicSegment(start, start + 10)); } } -- 2.34.1