segStore: allow benchmarks to specify the size of the store
[deliverable/tracecompass.git] / 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.0258 seconds and 5 git commands to generate.