org.openjdk.jmh.annotations.Setup类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.openjdk.jmh.annotations.Setup类的一些代码示例,展示了Setup类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Setup类的具体详情如下:
包路径:org.openjdk.jmh.annotations.Setup
类名称:Setup

Setup介绍

暂无

代码示例

代码示例来源:origin: goldmansachs/gs-collections

@Setup
public void setUp()
{
  Random random = new Random(123456789012345L);
  this.elements = new String[this.size];
  for (int i = 0; i < this.size; i++)
  {
    this.elements[i] = RandomStringUtils.random(RANDOM_COUNT, 0, 0, false, true, null, random);
  }
}

代码示例来源:origin: prestodb/presto

@Setup
public void setup()
{
  MetadataManager metadata = MetadataManager.createTestMetadataManager();
  ExpressionCompiler expressionCompiler = new ExpressionCompiler(
      metadata,
      new PageFunctionCompiler(metadata, 0));
  RowExpression projection = generateComplexComparisonProjection(FIELDS_COUNT, COMPARISONS_COUNT);
  compiledProcessor = expressionCompiler.compilePageProcessor(Optional.empty(), ImmutableList.of(projection)).get();
}

代码示例来源:origin: prestodb/presto

@Setup
public void setup()
{
  inputPage = createInputPage();
  MetadataManager metadata = MetadataManager.createTestMetadataManager();
  compiledProcessor = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0)).compilePageProcessor(Optional.of(FILTER), ImmutableList.of(PROJECT)).get();
}

代码示例来源:origin: apache/incubator-pinot

@Setup
public void setUp() {
 Random random = new Random(System.nanoTime());
 FixedIntArray[] uniqueValues = new FixedIntArray[CARDINALITY];
 for (int i = 0; i < uniqueValues.length; i++) {
  uniqueValues[i] = new FixedIntArray(
    new int[]{random.nextInt(COLUMN_CARDINALITY), random.nextInt(COLUMN_CARDINALITY), random.nextInt(
      COLUMN_CARDINALITY)});
 }
 _values = new FixedIntArray[ROW_COUNT];
 for (int i = 0; i < _values.length; i++) {
  _values[i] = uniqueValues[random.nextInt(CARDINALITY)];
 }
}

代码示例来源:origin: apache/incubator-druid

@Setup
public void setup()
{
 Random rand = ThreadLocalRandom.current();
 sequences = new ArrayList<>();
 for (int i = 0; i < count; i++) {
  int[] sequence = new int[sequenceLength];
  for (int j = 0; j < sequenceLength; j++) {
   sequence[j] = rand.nextInt();
  }
  sequences.add(Sequences.simple(Ints.asList(sequence)));
 }
}

代码示例来源:origin: prestodb/presto

@Setup
public void setup()
{
  switch (dataType) {
    case "VARCHAR":
      types = Collections.nCopies(channelCount, VARCHAR);
      pages = createVarcharPages(POSITIONS, groupCount, channelCount, hashEnabled);
      break;
    case "BIGINT":
      types = Collections.nCopies(channelCount, BIGINT);
      pages = createBigintPages(POSITIONS, groupCount, channelCount, hashEnabled);
      break;
    default:
      throw new UnsupportedOperationException("Unsupported dataType");
  }
  hashChannel = hashEnabled ? Optional.of(channelCount) : Optional.empty();
  channels = new int[channelCount];
  for (int i = 0; i < channelCount; i++) {
    channels[i] = i;
  }
}

代码示例来源:origin: apache/incubator-druid

@Setup
 public void setup(BitmapIterationBenchmark state)
 {
  double prob = Math.pow(state.prob, 1.0 / n);
  MutableBitmap[] mutableBitmaps = new MutableBitmap[n];
  for (int i = 0; i < n; i++) {
   mutableBitmaps[i] = state.factory.makeEmptyMutableBitmap();
  }
  Random r = ThreadLocalRandom.current();
  for (int i = 0; i < state.size; i++) {
   // unions are usually search/filter/select of multiple values of one dimension, so making bitmaps disjoint will
   // make benchmarks closer to actual workloads
   MutableBitmap bitmap = mutableBitmaps[r.nextInt(n)];
   // In one selected bitmap, set the bit with probability=prob, to have the same fraction of set bit in the union
   if (r.nextDouble() < prob) {
    bitmap.add(i);
   }
  }
  bitmaps = new ImmutableBitmap[n];
  for (int i = 0; i < n; i++) {
   bitmaps[i] = state.factory.makeImmutableBitmap(mutableBitmaps[i]);
  }
 }
}

代码示例来源:origin: prestodb/presto

@Setup
public void setup()
{
  Type type = TYPE_MAP.get(this.type);
  for (int i = 0; i < columnCount; i++) {
    Symbol symbol = new Symbol(type.getDisplayName().toLowerCase(ENGLISH) + i);
    symbolTypes.put(symbol, type);
    sourceLayout.put(symbol, i);
  }
  List<RowExpression> projections = getProjections(type);
  types = projections.stream().map(RowExpression::getType).collect(toList());
  MetadataManager metadata = createTestMetadataManager();
  PageFunctionCompiler pageFunctionCompiler = new PageFunctionCompiler(metadata, 0);
  inputPage = createPage(types, dictionaryBlocks);
  pageProcessor = new ExpressionCompiler(metadata, pageFunctionCompiler).compilePageProcessor(Optional.of(getFilter(type)), projections).get();
  recordSet = new PageRecordSet(types, inputPage);
  cursorProcessor = new ExpressionCompiler(metadata, pageFunctionCompiler).compileCursorProcessor(Optional.of(getFilter(type)), projections, "key").get();
}

代码示例来源:origin: micrometer-metrics/micrometer

@Setup(Level.Iteration)
  public void setup() {
    final Random r = new Random(1234567891L);
    dataIterator = Iterators.cycle(
        Stream.generate(() -> Math.round(Math.exp(2.0 + r.nextGaussian()))).limit(1048576)
            .collect(Collectors.toList()));
  }
}

代码示例来源:origin: apache/incubator-druid

@Setup(Level.Trial)
public void setup()
      "version",
      null,
      ImmutableList.of(),
      ImmutableList.of(),
      shardSpec,
      0,

代码示例来源:origin: mulesoft/mule

@Setup(Level.Trial)
public void setUp() {
 handler = new CompositeOperationPolicy(asList(new Policy(new PolicyChain() {
  @Override
  public Publisher<CoreEvent> apply(Publisher<CoreEvent> publisher) {
   return publisher;
  }
 }, "")), empty(), (policy, nextProcessor) -> nextProcessor);
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Setup
public void setup()
{
  inputPage = createInputPage();
  handCodedProcessor = new Tpch1FilterAndProject();
  compiledProcessor = new ExpressionCompiler(MetadataManager.createTestMetadataManager()).compilePageProcessor(FILTER, ImmutableList.of(PROJECT)).get();
}

代码示例来源:origin: prestodb/presto

@Setup
  public void setup()
  {
    ImmutableList.Builder<HivePartition> partitions = ImmutableList.builder();
    SchemaTableName table = new SchemaTableName("schema", "table");
    for (int i = 0; i < TOTAL_SIZE; i++) {
      partitions.add(new HivePartition(table, "partition_" + i, ImmutableMap.of()));
    }
    this.partitions = partitions.build();
  }
}

代码示例来源:origin: prestodb/presto

@Setup
  public void setup()
  {
    List<Type> types = ImmutableList.copyOf(limit(cycle(BIGINT), FIELDS_COUNT));
    ThreadLocalRandom random = ThreadLocalRandom.current();
    PageBuilder pageBuilder = new PageBuilder(types);
    while (!pageBuilder.isFull()) {
      pageBuilder.declarePosition();
      for (int channel = 0; channel < FIELDS_COUNT; channel++) {
        BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(channel);
        if (random.nextDouble() < NULLS_FRACTION) {
          blockBuilder.appendNull();
        }
        else {
          BIGINT.writeLong(blockBuilder, random.nextLong());
        }
      }
    }
    page = pageBuilder.build();
  }
}

代码示例来源:origin: apache/incubator-druid

@Setup
 public void setup(BitmapIterationBenchmark state)
 {
  data = new int[(int) (state.size * state.prob) * 2];
  dataSize = 0;
  Random random = ThreadLocalRandom.current();
  for (int bit = 0; bit < state.size; bit++) {
   if (random.nextDouble() < state.prob) {
    data[dataSize] = bit;
    dataSize++;
   }
  }
 }
}

代码示例来源:origin: prestodb/presto

@Setup
public void setup()
{
  pages = createBigintPages(POSITIONS, groupCount, channelCount, hashEnabled);
}

代码示例来源:origin: prestodb/presto

@Setup
public void setup()
{
  String tpch = "tpch";
  session = testSessionBuilder()
      .setCatalog(tpch)
      .setSchema("sf1")
      .setSystemProperty("iterative_optimizer_enabled", iterativeOptimizerEnabled)
      .build();
  queryRunner = new LocalQueryRunner(session);
  queryRunner.createCatalog(tpch, new TpchConnectorFactory(4), ImmutableMap.of(TPCH_COLUMN_NAMING_PROPERTY, ColumnNaming.STANDARD.name()));
  queries = IntStream.rangeClosed(1, 22)
      .boxed()
      .filter(i -> i != 15) // q15 has two queries in it
      .map(i -> readResource(String.format("/io/airlift/tpch/queries/q%d.sql", i)))
      .collect(toImmutableList());
}

代码示例来源:origin: prestodb/presto

@Setup
public void setup()
{
  MetadataManager metadata = MetadataManager.createTestMetadataManager();
  metadata.addFunctions(extractFunctions(BenchmarkArraySort.class));
  ExpressionCompiler compiler = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0));
  ImmutableList.Builder<RowExpression> projectionsBuilder = ImmutableList.builder();
  Block[] blocks = new Block[TYPES.size()];
  for (int i = 0; i < TYPES.size(); i++) {
    Type elementType = TYPES.get(i);
    ArrayType arrayType = new ArrayType(elementType);
    Signature signature = new Signature(name, FunctionKind.SCALAR, arrayType.getTypeSignature(), arrayType.getTypeSignature());
    projectionsBuilder.add(new CallExpression(signature, arrayType, ImmutableList.of(field(i, arrayType))));
    blocks[i] = createChannel(POSITIONS, ARRAY_SIZE, arrayType);
  }
  ImmutableList<RowExpression> projections = projectionsBuilder.build();
  pageProcessor = compiler.compilePageProcessor(Optional.empty(), projections).get();
  page = new Page(blocks);
}

代码示例来源:origin: io.prestosql/presto-main

@Setup
public void setup()
{
  inputPage = createInputPage();
  MetadataManager metadata = MetadataManager.createTestMetadataManager();
  compiledProcessor = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0)).compilePageProcessor(Optional.of(FILTER), ImmutableList.of(PROJECT)).get();
}

代码示例来源:origin: JCTools/JCTools

@Setup(Level.Trial)
public void prepare() throws Exception {
  set = createSet(type, size);
  Random r = new Random(666);
  for (int i = 0; i < occupancy - 1; i++) {
    set.add(new Key(r.nextInt(keyBound)));
  }
  key = new Key(r.nextInt(keyBound));
  set.add(key);
}

相关文章

Setup类方法