Search in sources :

Example 16 with BeforeExperiment

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);
}
Also used : Random(java.util.Random) BitSet(java.util.BitSet) BeforeExperiment(com.google.caliper.BeforeExperiment)

Example 17 with BeforeExperiment

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;
    }
}
Also used : Random(java.util.Random) BeforeExperiment(com.google.caliper.BeforeExperiment)

Example 18 with BeforeExperiment

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);
}
Also used : Random(java.util.Random) BeforeExperiment(com.google.caliper.BeforeExperiment)

Example 19 with BeforeExperiment

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);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Random(java.util.Random) ArrayList(java.util.ArrayList) BeforeExperiment(com.google.caliper.BeforeExperiment)

Example 20 with BeforeExperiment

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]);
    }
}
Also used : Random(java.util.Random) BeforeExperiment(com.google.caliper.BeforeExperiment)

Aggregations

BeforeExperiment (com.google.caliper.BeforeExperiment)28 Random (java.util.Random)13 SpannableString (android.text.SpannableString)5 File (java.io.File)5 FileOutputStream (java.io.FileOutputStream)5 PrintWriter (java.io.PrintWriter)5 Footprint (com.google.caliper.api.Footprint)3 BitSet (java.util.BitSet)2 BuckConfig (com.facebook.buck.cli.BuckConfig)1 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)1 BroadcastEventListener (com.facebook.buck.event.listener.BroadcastEventListener)1 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)1 ConstructorArgMarshaller (com.facebook.buck.rules.ConstructorArgMarshaller)1 TestCellBuilder (com.facebook.buck.rules.TestCellBuilder)1 DefaultTypeCoercerFactory (com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 GetCheckedTypeValidator (com.google.common.util.concurrent.FuturesGetChecked.GetCheckedTypeValidator)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1