io.netty.channel.ServerChannel#org.openjdk.jmh.annotations.Setup源码实例Demo

下面列出了io.netty.channel.ServerChannel#org.openjdk.jmh.annotations.Setup 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: presto   文件: BenchmarkTopNOperator.java
@Setup
public void setup()
{
    executor = newCachedThreadPool(daemonThreadsNamed("test-executor-%s"));
    scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s"));

    List<Type> types = ImmutableList.of(DOUBLE, DOUBLE, VARCHAR, DOUBLE);
    pages = createInputPages(Integer.valueOf(positionsPerPage), types);
    operatorFactory = TopNOperator.createOperatorFactory(
            0,
            new PlanNodeId("test"),
            types,
            Integer.valueOf(topN),
            ImmutableList.of(0, 2),
            ImmutableList.of(DESC_NULLS_LAST, ASC_NULLS_FIRST));
}
 
源代码2 项目: presto   文件: BenchmarkDecimalOperators.java
@Setup
public void setup()
{
    addSymbol("d1", DOUBLE);
    addSymbol("d2", DOUBLE);
    addSymbol("d3", DOUBLE);
    addSymbol("d4", DOUBLE);

    addSymbol("s1", createDecimalType(10, 5));
    addSymbol("s2", createDecimalType(7, 2));
    addSymbol("s3", createDecimalType(12, 2));
    addSymbol("s4", createDecimalType(2, 1));

    addSymbol("l1", createDecimalType(35, 10));
    addSymbol("l2", createDecimalType(25, 5));
    addSymbol("l3", createDecimalType(20, 6));
    addSymbol("l4", createDecimalType(25, 8));

    generateRandomInputPage();
    generateProcessor(expression);
}
 
源代码3 项目: netty-4.1.22   文件: RedisEncoderBenchmark.java
@Setup(Level.Trial)
public void setup() {
    byte[] bytes = new byte[256];
    content = Unpooled.buffer(bytes.length);
    content.writeBytes(bytes);
    ByteBuf testContent = Unpooled.unreleasableBuffer(content.asReadOnly());

    List<RedisMessage> rList = new ArrayList<RedisMessage>(arraySize);
    for (int i = 0; i < arraySize; ++i) {
        rList.add(new FullBulkStringRedisMessage(testContent));
    }
    redisArray = new ArrayRedisMessage(rList);
    encoder = new RedisEncoder();
    context = new EmbeddedChannelWriteReleaseHandlerContext(pooledAllocator ? PooledByteBufAllocator.DEFAULT :
            UnpooledByteBufAllocator.DEFAULT, encoder) {
        @Override
        protected void handleException(Throwable t) {
            handleUnexpectedException(t);
        }
    };
}
 
源代码4 项目: presto   文件: BenchmarkArrayDistinct.java
@Setup
public void setup()
{
    Metadata metadata = createTestMetadataManager();
    metadata.addFunctions(extractFunctions(BenchmarkArrayDistinct.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);
        projectionsBuilder.add(new CallExpression(
                metadata.resolveFunction(QualifiedName.of(name), fromTypes(arrayType)),
                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);
}
 
源代码5 项目: presto   文件: BenchmarkMapCopy.java
@Setup
public void setup()
{
    MapType mapType = mapType(VARCHAR, BIGINT);
    blockBuilder = mapType.createBlockBuilder(null, POSITIONS);
    for (int position = 0; position < POSITIONS; position++) {
        BlockBuilder entryBuilder = blockBuilder.beginBlockEntry();
        for (int i = 0; i < mapSize; i++) {
            VARCHAR.writeString(entryBuilder, String.valueOf(ThreadLocalRandom.current().nextInt()));
            BIGINT.writeLong(entryBuilder, ThreadLocalRandom.current().nextInt());
        }
        blockBuilder.closeEntry();
    }

    dataBlock = blockBuilder.build();
}
 
源代码6 项目: presto   文件: BenchmarkInequalityJoin.java
@Setup
public void setUp()
{
    queryRunner = new MemoryLocalQueryRunner(ImmutableMap.of(SystemSessionProperties.FAST_INEQUALITY_JOINS, fastInequalityJoins));

    // t1.val1 is in range [0, 1000)
    // t1.bucket is in [0, 1000)
    queryRunner.execute(format(
            "CREATE TABLE memory.default.t1 AS SELECT " +
                    "orderkey %% %d bucket, " +
                    "(orderkey * 13) %% 1000 val1 " +
                    "FROM tpch.tiny.lineitem",
            buckets));
    // t2.val2 is in range [0, 10)
    // t2.bucket is in [0, 1000)
    queryRunner.execute(format(
            "CREATE TABLE memory.default.t2 AS SELECT " +
                    "orderkey %% %d bucket, " +
                    "(orderkey * 379) %% %d val2 " +
                    "FROM tpch.tiny.lineitem",
            buckets,
            filterOutCoefficient));
}
 
源代码7 项目: netty-4.1.22   文件: SlicedByteBufBenchmark.java
@Setup
public void setup() {
    // Use buffer sizes that will also allow to write UTF-8 without grow the buffer
    ByteBuf buffer = Unpooled.buffer(512).retain();
    slicedByteBuf = buffer.slice(0, 256);
    slicedAbstractByteBuf = buffer.slice(0, 256);

    if (slicedByteBuf.getClass() == slicedAbstractByteBuf.getClass()) {
        throw new IllegalStateException();
    }

    StringBuilder asciiSequence = new StringBuilder(128);
    for (int i = 0; i < 128; i++) {
        asciiSequence.append('a');
    }
    ascii = asciiSequence.toString();
}
 
@Setup(Level.Iteration)
public void setup() throws SpellCheckException, IOException {
  SpellCheckSettings spellCheckSettings = SpellCheckSettings.builder()
      .maxEditDistance(maxEditDistance).build();

  DataHolder dataHolder = new InMemoryDataHolder(spellCheckSettings,
      new Murmur3HashFunction());

  spellChecker = new SymSpellCheck(dataHolder,
      getStringDistance(spellCheckSettings, null),
      spellCheckSettings);
  indexData(dataFile, dataHolder);
  System.out.println(" DataHolder Indexed Size " + dataHolder.getSize()
  );

}
 
源代码9 项目: netty-4.1.22   文件: IntObjectHashMapBenchmark.java
@Setup(Level.Trial)
public void setup() {
    switch(mapType) {
        case AGRONA: {
            environment = new AgronaEnvironment();
            break;
        }
        case NETTY: {
            environment = new NettyEnvironment();
            break;
        }
        default: {
            throw new IllegalStateException("Invalid mapType: " + mapType);
        }
    }
}
 
源代码10 项目: presto   文件: BenchmarkArrayJoin.java
@Setup
public void setup()
{
    Metadata metadata = createTestMetadataManager();

    List<RowExpression> projections = ImmutableList.of(new CallExpression(
            metadata.resolveFunction(QualifiedName.of("array_join"), fromTypes(new ArrayType(BIGINT), VARCHAR)),
            VARCHAR,
            ImmutableList.of(field(0, new ArrayType(BIGINT)), constant(Slices.wrappedBuffer(",".getBytes(UTF_8)), VARCHAR))));

    pageProcessor = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0))
            .compilePageProcessor(Optional.empty(), projections)
            .get();

    page = new Page(createChannel(POSITIONS, ARRAY_SIZE));
}
 
@Setup
public void setup()
{
    switch (hashColumns) {
        case "varchar":
            hashChannels = Ints.asList(0);
            break;
        case "bigint":
            hashChannels = Ints.asList(1);
            break;
        case "all":
            hashChannels = Ints.asList(0, 1, 2);
            break;
        default:
            throw new UnsupportedOperationException(format("Unknown hashColumns value [%s]", hashColumns));
    }
    executor = newCachedThreadPool(daemonThreadsNamed("test-executor-%s"));
    scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s"));

    initializeBuildPages();
}
 
源代码12 项目: presto   文件: BenchmarkGroupByHash.java
@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;
    }
}
 
源代码13 项目: smithy   文件: Selectors.java
@Setup
public void prepare() {
    model = Model.assembler()
            .addImport(Selectors.class.getResource("http-model.smithy"))
            .assemble()
            .getResult()
            .get();
}
 
源代码14 项目: FHIR   文件: FHIRValueSetBenchmarks.java
@SuppressWarnings("unchecked")
@Setup
public void setUp() throws Exception {
    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("ValueSet-large-HashSet.ser");
    try (ObjectInputStream is = new ObjectInputStream(in)) {
        set = (Set<String>) is.readObject();
    }
}
 
源代码15 项目: hadoop-ozone   文件: BenchmarkBlockDataToString.java
@Setup
public void createData() {
  ThreadLocalRandom rnd = ThreadLocalRandom.current();
  data = new ArrayList<>(count);
  values = new ArrayList<>(count);
  for (int i = 0; i < count; i++) {
    BlockID blockID = new BlockID(rnd.nextLong(), rnd.nextLong());
    BlockData item = new BlockData(blockID);
    item.setBlockCommitSequenceId(rnd.nextLong());
    data.add(item);
    values.add(item.toString());
  }
}
 
源代码16 项目: hadoop-ozone   文件: BenchMarkSCM.java
@Setup(Level.Trial)
public static void initialize()
    throws Exception {
  try {
    lock.lock();
    if (scm == null) {
      OzoneConfiguration conf = new OzoneConfiguration();
      testDir = GenesisUtil.getTempPath()
          .resolve(RandomStringUtils.randomNumeric(7)).toString();
      conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir);

      GenesisUtil.configureSCM(conf, 10);
      conf.setInt(OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT,
          numContainersPerPipeline);
      GenesisUtil.addPipelines(ReplicationFactor.THREE, numPipelines, conf);

      scm = GenesisUtil.getScm(conf, new SCMConfigurator());
      scm.start();
      blockManager = scm.getScmBlockManager();

      // prepare SCM
      PipelineManager pipelineManager = scm.getPipelineManager();
      for (Pipeline pipeline : pipelineManager
          .getPipelines(ReplicationType.RATIS, ReplicationFactor.THREE)) {
        pipelineManager.openPipeline(pipeline.getId());
      }
      scm.getEventQueue().fireEvent(SCMEvents.SAFE_MODE_STATUS,
          new SCMSafeModeManager.SafeModeStatus(false, false));
      Thread.sleep(1000);
    }
  } finally {
    lock.unlock();
  }
}
 
源代码17 项目: presto   文件: BenchmarkBigIntOperators.java
@Setup
public void setup()
{
    leftOperand0 = 1;
    leftOperand1 = 20;
    leftOperand2 = 33;
    leftOperand3 = 407;
    leftOperand4 = 7890;

    rightOperand0 = 123456;
    rightOperand1 = 9003;
    rightOperand2 = 809;
    rightOperand3 = 67;
    rightOperand4 = 5;
}
 
源代码18 项目: grpc-nebula-java   文件: WriteBenchmark.java
@Setup
public void setup() {
  context = Context.ROOT;
  for (int i = 0; i < preexistingKeys; i++) {
    context = context.withValue(Context.key("preexisting_key" + i), val);
  }
}
 
源代码19 项目: presto   文件: BenchmarkReorderChainedJoins.java
@Setup
public void setup()
{
    Session session = testSessionBuilder()
            .setSystemProperty("join_reordering_strategy", joinReorderingStrategy)
            .setSystemProperty("join_distribution_type", "AUTOMATIC")
            .setCatalog("tpch")
            .setSchema("tiny")
            .build();
    queryRunner = LocalQueryRunner.create(session);
    queryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
}
 
源代码20 项目: FHIR   文件: FHIRParserBenchmark.java
@Setup
public void setUp() throws IOException {
    if (exampleName == null) {
        System.err.println("exampleName is null; if you're in Eclipse then make sure annotation processing is on and you've ran 'mvn clean package'.");
        System.exit(1);
    }
    System.out.println("Setting up for example " + exampleName);
    context = FhirContext.forR4();
    context.setParserErrorHandler(new StrictErrorHandler());
    JSON_SPEC_EXAMPLE = BenchmarkUtil.getSpecExample(Format.JSON, exampleName);
    XML_SPEC_EXAMPLE = BenchmarkUtil.getSpecExample(Format.XML, exampleName);
}
 
@Setup(Level.Iteration)
public void setup() throws SpellCheckException, IOException {
  SpellCheckSettings spellCheckSettings = SpellCheckSettings.builder()
      .maxEditDistance(maxEditDistance).build();

  DataHolder dataHolder = new InMemoryDataHolder(spellCheckSettings,
      new Murmur3HashFunction());

  spellChecker = new SymSpellCheck(dataHolder,
      getStringDistance(spellCheckSettings, null),
      spellCheckSettings);

}
 
源代码22 项目: grpc-nebula-java   文件: UnaryCallQpsBenchmark.java
/**
 * Setup with direct executors, small payloads and a large flow control window.
 */
@Setup(Level.Trial)
public void setup() throws Exception {
  super.setup(ExecutorType.DIRECT,
      ExecutorType.DIRECT,
      MessageSize.SMALL,
      MessageSize.SMALL,
      FlowWindowSize.LARGE,
      ChannelType.NIO,
      maxConcurrentStreams,
      channelCount);
  callCounter = new AtomicLong();
  completed = new AtomicBoolean();
  startUnaryCalls(maxConcurrentStreams, callCounter, completed, 1);
}
 
源代码23 项目: netty-4.1.22   文件: ByteBufBenchmark.java
@Setup
public void setup() {
    byteBuffer = ByteBuffer.allocate(8);
    directByteBuffer = ByteBuffer.allocateDirect(8);
    buffer = Unpooled.buffer(8);
    directBuffer = Unpooled.directBuffer(8);
    directBufferPooled = PooledByteBufAllocator.DEFAULT.directBuffer(8);
}
 
源代码24 项目: presto   文件: BenchmarkJsonToMapCast.java
@Setup
public void setup()
{
    Type valueType;
    switch (valueTypeName) {
        case "BIGINT":
            valueType = BIGINT;
            break;
        case "DOUBLE":
            valueType = DOUBLE;
            break;
        case "VARCHAR":
            valueType = VARCHAR;
            break;
        default:
            throw new UnsupportedOperationException();
    }

    Metadata metadata = createTestMetadataManager();
    MapType mapType = mapType(VARCHAR, valueType);
    List<RowExpression> projections = ImmutableList.of(new CallExpression(
            metadata.getCoercion(JSON, mapType),
            mapType,
            ImmutableList.of(field(0, JSON))));

    pageProcessor = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0))
            .compilePageProcessor(Optional.empty(), projections)
            .get();

    page = new Page(createChannel(POSITION_COUNT, MAP_SIZE, valueType));
}
 
/**
 * Set up the registry.
 */
@Setup(Level.Trial)
public void setup() throws Exception {
  registry = new MutableHandlerRegistry();
  fullMethodNames = new ArrayList<>(serviceCount * methodCountPerService);
  for (int serviceIndex = 0; serviceIndex < serviceCount; ++serviceIndex) {
    String serviceName = randomString();
    ServerServiceDefinition.Builder serviceBuilder = ServerServiceDefinition.builder(serviceName);
    for (int methodIndex = 0; methodIndex < methodCountPerService; ++methodIndex) {
      String methodName = randomString();

      MethodDescriptor<Void, Void> methodDescriptor = MethodDescriptor.<Void, Void>newBuilder()
          .setType(MethodDescriptor.MethodType.UNKNOWN)
          .setFullMethodName(MethodDescriptor.generateFullMethodName(serviceName, methodName))
          .setRequestMarshaller(TestMethodDescriptors.voidMarshaller())
          .setResponseMarshaller(TestMethodDescriptors.voidMarshaller())
          .build();
      serviceBuilder.addMethod(methodDescriptor,
          new ServerCallHandler<Void, Void>() {
            @Override
            public Listener<Void> startCall(ServerCall<Void, Void> call,
                Metadata headers) {
              return null;
            }
          });
      fullMethodNames.add(methodDescriptor.getFullMethodName());
    }
    registry.addService(serviceBuilder.build());
  }
}
 
源代码26 项目: presto   文件: BenchmarkEnvelopeIntersection.java
@Setup
public void setup()
{
    geometry = stGeometryFromText(utf8Slice("POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))"));
    otherGeometry = stGeometryFromText(utf8Slice("POLYGON ((0.5 0.5, 0.5 1.5, 1.5 1.5, 1.5 0.5, 0.5 0.5))"));
    envelope = stEnvelope(geometry);
    otherEnvelope = stEnvelope(otherGeometry);
}
 
源代码27 项目: netty-4.1.22   文件: HeapByteBufBenchmark.java
@Setup
public void setup() throws Exception {
    unsafeBuffer = newBuffer("io.netty.buffer.UnpooledUnsafeHeapByteBuf");
    buffer = newBuffer("io.netty.buffer.UnpooledHeapByteBuf");
    unsafeBuffer.writeLong(1L);
    buffer.writeLong(1L);
}
 
源代码28 项目: presto   文件: BenchmarkGeometryToBingTiles.java
@Setup
public void setup()
        throws IOException
{
    Path filePath = Paths.get(this.getClass().getClassLoader().getResource("large_polygon.txt").getPath());
    List<String> lines = Files.readAllLines(filePath);
    String line = lines.get(0);
    String[] parts = line.split("\\|");
    String wkt = parts[0];
    geometry = GeoFunctions.stGeometryFromText(Slices.utf8Slice(wkt));
    envelope = GeoFunctions.stEnvelope(geometry);
    zoomLevel = Integer.parseInt(parts[1]);
}
 
源代码29 项目: presto   文件: BenchmarkRegexpFunctions.java
@Setup
public void setup()
{
    SliceOutput sliceOutput = new DynamicSliceOutput(sourceLength);
    Slice pattern;
    switch (patternString) {
        case ".*x.*":
            pattern = Slices.utf8Slice(".*x.*");
            IntStream.generate(() -> 97).limit(sourceLength).forEach(sliceOutput::appendByte);
            break;
        case ".*(x|y).*":
            pattern = Slices.utf8Slice(".*(x|y).*");
            IntStream.generate(() -> 97).limit(sourceLength).forEach(sliceOutput::appendByte);
            break;
        case "longdotstar":
            pattern = Slices.utf8Slice(".*coolfunctionname.*");
            ThreadLocalRandom.current().ints(97, 123).limit(sourceLength).forEach(sliceOutput::appendByte);
            break;
        case "phone":
            pattern = Slices.utf8Slice("\\d{3}/\\d{3}/\\d{4}");
            // 47: '/', 48-57: '0'-'9'
            ThreadLocalRandom.current().ints(47, 58).limit(sourceLength).forEach(sliceOutput::appendByte);
            break;
        case "literal":
            pattern = Slices.utf8Slice("literal");
            // 97-122: 'a'-'z'
            ThreadLocalRandom.current().ints(97, 123).limit(sourceLength).forEach(sliceOutput::appendByte);
            break;
        default:
            throw new IllegalArgumentException("pattern: " + patternString + " not supported");
    }

    joniPattern = joniRegexp(pattern);
    re2JPattern = re2JRegexp(pattern);
    source = sliceOutput.slice();
    checkState(source.length() == sourceLength, "source.length=%s, sourceLength=%s", source.length(), sourceLength);
}
 
源代码30 项目: sdn-rx   文件: Benchmarks.java
@Setup
public void setup() {
	Map<String, Object> neo4jConfig = prepareNeo4j();

	SpringApplication springApplication = new SpringApplication();
	springApplication.addPrimarySources(Collections.singletonList(Application.class));
	springApplication.setLazyInitialization(true);
	springApplication.setDefaultProperties(neo4jConfig);

	this.applicationContext = springApplication.run();
	this.movieRepository = applicationContext.getBean(MovieRepository.class);
	this.driver = applicationContext.getBean(Driver.class);
}