segStore: allow benchmarks to specify the size of the store
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Thu, 20 Oct 2016 20:43:01 +0000 (16:43 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Tue, 1 Nov 2016 18:44:23 +0000 (14:44 -0400)
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 <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/83636
Reviewed-by: Hudson CI
statesystem/org.eclipse.tracecompass.segmentstore.core.tests/perf/org/eclipse/tracecompass/analysis/timing/core/tests/store/SegmentStoreBenchmark.java

index 1dc8c8aff3084f2b842ea8287efb214d42de36b2..246e8f0bf3d486aad3a8328642d43902199527be 100644 (file)
@@ -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));
         }
     }
This page took 0.027333 seconds and 5 git commands to generate.