Uploaded image for project: 'Commons RNG'
  1. Commons RNG
  2. RNG-114

Improve ListSampler shuffle algorithm to detect instances of RandomAccess

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Implemented
    • 1.2
    • 1.3
    • sampling
    • None

    Description

      The ListSampler shuffle algorithm uses the input list set(index) method. If this runs in constant time then the algorithm is fast. If the list is not an instance of java.util.RandomAccess such as a LinkedList the algorithm will suffer from performance slowdown for large lists.

      This is handled in the JDK Collections.shuffle method by detecting if the list is not an instance of RandomAccess. If so the list set(index) method is avoided and the list is traversed for update using its iterator.

      Tasks:

      • Benchmark the ListSampler method verses Collections.shuffle with ArrayList and LinkedList
      • Update the ListSampler to have comparable performance to Collections.shuffle

      Attachments

        1. LinkedListShufflePerformance.png
          27 kB
          Alex Herbert

        Issue Links

          Activity

            People

              aherbert Alex Herbert
              aherbert Alex Herbert
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m