Class ListShuffleBenchmark
- java.lang.Object
-
- org.apache.commons.rng.examples.jmh.sampling.ListShuffleBenchmark
-
public class ListShuffleBenchmark extends Object
Executes benchmark to compare the speed of shuffling aList.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classListShuffleBenchmark.LinkedListDataThe LinkedList to shuffle.static classListShuffleBenchmark.ListDataThe list to shuffle.static classListShuffleBenchmark.ShuffleDataThe data for the shuffle.
-
Constructor Summary
Constructors Constructor Description ListShuffleBenchmark()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intbaselineRandom(ListShuffleBenchmark.ShuffleData data)Baseline a shuffle using the Random.intbaselineRNG(ListShuffleBenchmark.ShuffleData data)Baseline a shuffle using the UniformRandomProvider.intbaselineRNG2(ListShuffleBenchmark.ShuffleData data)Baseline a shuffle using the UniformRandomProvider.intbaselineRNG3(ListShuffleBenchmark.ShuffleData data)Baseline a shuffle using the UniformRandomProvider.ObjectshuffleDirect(ListShuffleBenchmark.LinkedListData data)Performs a direct shuffle on a LinkedList.ObjectshuffleIterator(ListShuffleBenchmark.LinkedListData data)Performs a shuffle on a LinkedList using an iterator.ObjectusingCollections(ListShuffleBenchmark.ListData data)Performs a shuffle using java.utils.Collections.ObjectusingDirectRandomAccess(ListShuffleBenchmark.ListData data)Performs a direct shuffle on the list using JDK Collections method.ObjectusingDirectRandomAccessDirectionalBidirectional(ListShuffleBenchmark.ListData data)Performs a direct shuffle on the list using JDK Collections method modified to handle a directional shuffle from a start index.ObjectusingDirectRandomAccessSublistBidirectional(ListShuffleBenchmark.ListData data)Performs a direct shuffle on the list using JDK Collections method modified to handle a directional shuffle from a start index by extracting a sub-list.ObjectusingListSampler(ListShuffleBenchmark.ListData data)Performs a shuffle using the current ListSampler shuffle.ObjectusingListSamplerBidirectional(ListShuffleBenchmark.ListData data)Performs a shuffle using the current ListSampler shuffle.ObjectusingPermutationSampler(ListShuffleBenchmark.ListData data)Performs a shuffle using ListSampler shuffle method from version 1.2 which delegates to the PermuationSampler.ObjectusingPermutationSamplerBidirectional(ListShuffleBenchmark.ListData data)Performs a shuffle using ListSampler shuffle method from version 1.2 which delegates to the PermuationSampler.ObjectusingPermutationSamplerRandomAccess(ListShuffleBenchmark.ListData data)Performs a shuffle using ListSampler shuffle method from version 1.2 which delegates to the PermuationSampler.ObjectusingPermutationSamplerRandomAccessBidirectional(ListShuffleBenchmark.ListData data)Performs a shuffle using ListSampler shuffle method from version 1.2 which delegates to the PermuationSampler.
-
-
-
Constructor Detail
-
ListShuffleBenchmark
public ListShuffleBenchmark()
-
-
Method Detail
-
baselineRandom
public int baselineRandom(ListShuffleBenchmark.ShuffleData data)
Baseline a shuffle using the Random. This is the in java.util.Collections that decrements to above one. This should be the same speed as the benchmark using UniformRandomProvider.- Parameters:
data- Shuffle data.- Returns:
- the sum
-
baselineRNG
public int baselineRNG(ListShuffleBenchmark.ShuffleData data)
Baseline a shuffle using the UniformRandomProvider. This should be the same speed as the benchmark using Random.- Parameters:
data- Shuffle data.- Returns:
- the sum
-
baselineRNG2
public int baselineRNG2(ListShuffleBenchmark.ShuffleData data)
Baseline a shuffle using the UniformRandomProvider. This should be the same speed as the benchmark using Random.- Parameters:
data- Shuffle data.- Returns:
- the sum
-
baselineRNG3
public int baselineRNG3(ListShuffleBenchmark.ShuffleData data)
Baseline a shuffle using the UniformRandomProvider. This should be the same speed as the benchmark using Random. This uses a variant that decrements to above zero so that the index i is one of the indices to swap. This is included to determine if there is a difference.- Parameters:
data- Shuffle data.- Returns:
- the sum
-
usingCollections
public Object usingCollections(ListShuffleBenchmark.ListData data)
Performs a shuffle using java.utils.Collections.- Parameters:
data- Shuffle data.- Returns:
- the list
-
usingPermutationSampler
public Object usingPermutationSampler(ListShuffleBenchmark.ListData data)
Performs a shuffle using ListSampler shuffle method from version 1.2 which delegates to the PermuationSampler.- Parameters:
data- Shuffle data.- Returns:
- the list
-
usingPermutationSamplerBidirectional
public Object usingPermutationSamplerBidirectional(ListShuffleBenchmark.ListData data)
Performs a shuffle using ListSampler shuffle method from version 1.2 which delegates to the PermuationSampler. This performs two part shuffles from the middle towards the head and then towards the end.- Parameters:
data- Shuffle data.- Returns:
- the list
-
usingPermutationSamplerRandomAccess
public Object usingPermutationSamplerRandomAccess(ListShuffleBenchmark.ListData data)
Performs a shuffle using ListSampler shuffle method from version 1.2 which delegates to the PermuationSampler. The method has been modified to detect RandomAccess lists.- Parameters:
data- Shuffle data.- Returns:
- the list
-
usingPermutationSamplerRandomAccessBidirectional
public Object usingPermutationSamplerRandomAccessBidirectional(ListShuffleBenchmark.ListData data)
Performs a shuffle using ListSampler shuffle method from version 1.2 which delegates to the PermuationSampler. The method has been modified to detect RandomAccess lists. This performs two part shuffles from the middle towards the head and then towards the end.- Parameters:
data- Shuffle data.- Returns:
- the list
-
usingDirectRandomAccess
public Object usingDirectRandomAccess(ListShuffleBenchmark.ListData data)
Performs a direct shuffle on the list using JDK Collections method.- Parameters:
data- Shuffle data.- Returns:
- the list
-
usingDirectRandomAccessDirectionalBidirectional
public Object usingDirectRandomAccessDirectionalBidirectional(ListShuffleBenchmark.ListData data)
Performs a direct shuffle on the list using JDK Collections method modified to handle a directional shuffle from a start index. This performs two part shuffles from the middle towards the head and then towards the end.- Parameters:
data- Shuffle data.- Returns:
- the list
-
usingDirectRandomAccessSublistBidirectional
public Object usingDirectRandomAccessSublistBidirectional(ListShuffleBenchmark.ListData data)
Performs a direct shuffle on the list using JDK Collections method modified to handle a directional shuffle from a start index by extracting a sub-list. This performs two part shuffles from the middle towards the head and then towards the end.- Parameters:
data- Shuffle data.- Returns:
- the list
-
usingListSampler
public Object usingListSampler(ListShuffleBenchmark.ListData data)
Performs a shuffle using the current ListSampler shuffle.- Parameters:
data- Shuffle data.- Returns:
- the list
-
usingListSamplerBidirectional
public Object usingListSamplerBidirectional(ListShuffleBenchmark.ListData data)
Performs a shuffle using the current ListSampler shuffle. This performs two part shuffles from the middle towards the head and then towards the end.- Parameters:
data- Shuffle data.- Returns:
- the list
-
shuffleDirect
public Object shuffleDirect(ListShuffleBenchmark.LinkedListData data)
Performs a direct shuffle on a LinkedList.- Parameters:
data- Shuffle data.- Returns:
- the list
-
shuffleIterator
public Object shuffleIterator(ListShuffleBenchmark.LinkedListData data)
Performs a shuffle on a LinkedList using an iterator.- Parameters:
data- Shuffle data.- Returns:
- the list
-
-