use of com.google.caliper.BeforeExperiment in project guava by google.
the class WhitespaceMatcherBenchmark method setUp.
@BeforeExperiment
protected void setUp() {
BitSet bitSet = new BitSet();
for (int i = 0; i < OLD_WHITESPACE_TABLE.length(); i++) {
bitSet.set(OLD_WHITESPACE_TABLE.charAt(i));
}
bitSet.clear(0);
bitSet.clear(1);
matcher = useNew ? CharMatcher.whitespace() : OLD_WHITESPACE;
teststring = newTestString(new Random(1), bitSet, percentMatching);
}
use of com.google.caliper.BeforeExperiment in project guava by google.
the class ComparatorDelegationOverheadBenchmark method setUp.
@BeforeExperiment
void setUp() throws Exception {
Random rng = new Random();
for (int i = 0; i < 0x100; i++) {
Integer[] array = new Integer[n];
for (int j = 0; j < n; j++) {
array[j] = rng.nextInt();
}
inputArrays[i] = array;
}
}
use of com.google.caliper.BeforeExperiment in project guava by google.
the class MultisetIteratorBenchmark method setUp.
@BeforeExperiment
void setUp() {
hashMultiset = HashMultiset.create(size);
linkedHashMultiset = LinkedHashMultiset.create(size);
treeMultiset = TreeMultiset.create();
Random random = new Random();
int sizeRemaining = size;
// TODO(kevinb): generate better test contents for multisets
for (int i = 0; sizeRemaining > 0; i++) {
// The JVM will return interned values for small ints.
Integer value = random.nextInt(1000) + 128;
int count = Math.min(random.nextInt(10) + 1, sizeRemaining);
sizeRemaining -= count;
hashMultiset.add(value, count);
linkedHashMultiset.add(value, count);
treeMultiset.add(value, count);
}
//TODO(kevinb): convert to assert once benchmark tests enable asserts by default
Preconditions.checkState(hashMultiset.size() == size);
}
use of com.google.caliper.BeforeExperiment in project guava by google.
the class SortedCopyBenchmark method setUp.
@BeforeExperiment
void setUp() {
checkArgument(size > 0, "empty collection not supported");
Set<Integer> set = new LinkedHashSet<Integer>(size);
Random random = new Random();
while (set.size() < size) {
set.add(random.nextInt());
}
List<Integer> list = new ArrayList<Integer>(set);
inputOrder.arrange(list);
input = ImmutableList.copyOf(list);
}
use of com.google.caliper.BeforeExperiment in project guava by google.
the class BaseEncodingBenchmark method setUp.
@BeforeExperiment
public void setUp() {
Random rng = new Random();
for (int i = 0; i < encodingInputs.length; i++) {
encodingInputs[i] = new byte[n];
rng.nextBytes(encodingInputs[i]);
decodingInputs[i] = encoding.encoding.encode(encodingInputs[i]);
}
}
Aggregations