Example usage for com.google.common.collect ImmutableList of

List of usage examples for com.google.common.collect ImmutableList of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList of.

Prototype

public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) 

Source Link

Usage

From source file:io.prestosql.execution.executor.SplitGenerators.java

public static void main(String[] args) {
    Histogram<Long> bins = fromContinuous(ImmutableList.of(MILLISECONDS.toNanos(0), MILLISECONDS.toNanos(1),
            MILLISECONDS.toNanos(10), MILLISECONDS.toNanos(100), MILLISECONDS.toNanos(1_000),
            MILLISECONDS.toNanos(10_000), MILLISECONDS.toNanos(60_000), MILLISECONDS.toNanos(300_000),
            MINUTES.toNanos(20), DAYS.toNanos(1)));

    IntermediateSplitGenerator intermediateSplitGenerator = new IntermediateSplitGenerator(null);
    List<IntermediateSplitSpecification> intermediateSpecs = new ArrayList<>();
    for (int i = 0; i < 10_000; i++) {
        IntermediateSplitSpecification next = intermediateSplitGenerator.next();
        intermediateSpecs.add(next);//from   w w  w .  j  a  va  2s.co  m
    }

    System.out.println("Scheduled time distributions");
    System.out.println("============================");
    System.out.println();
    System.out.println("Tasks with 8x " + IntermediateSplitGenerator.class.getSimpleName());
    bins.printDistribution(intermediateSpecs, t -> t.getScheduledTimeNanos() * 8, a -> 1,
            Duration::succinctNanos, a -> "");

    List<SplitGenerator> leafSplitGenerators = ImmutableList.of(new FastLeafSplitGenerator(),
            new SlowLeafSplitGenerator(), new L4LeafSplitGenerator(), new QuantaExceedingSplitGenerator(),
            new AggregatedLeafSplitGenerator());

    for (SplitGenerator generator : leafSplitGenerators) {
        List<SplitSpecification> leafSpecs = new ArrayList<>();
        for (int i = 0; i < 17000; i++) {
            leafSpecs.add(generator.next());
        }

        System.out.println();
        System.out.println("Tasks with 4x " + generator.getClass().getSimpleName());
        bins.printDistribution(leafSpecs, t -> t.getScheduledTimeNanos() * 4, Duration::succinctNanos);

        System.out.println("Per quanta:");
        bins.printDistribution(leafSpecs, SplitSpecification::getPerQuantaNanos, Duration::succinctNanos);
    }
}