io.netty.handler.codec.http2.DefaultHttp2Connection #org.openjdk.jmh.annotations.Level源码实例Demo

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

源代码1 项目: hadoop-ozone   文件: BenchMarkOzoneManager.java
@TearDown(Level.Trial)
public static void tearDown() {
  try {
    lock.lock();
    if (scm != null) {
      scm.stop();
      scm.join();
      scm = null;
      om.stop();
      om.join();
      om = null;
      FileUtil.fullyDelete(new File(testDir));
    }
  } finally {
    lock.unlock();
  }
}
 
源代码2 项目: headlong   文件: MeasureKeyValuePairSort.java
@Setup(Level.Invocation)
public void init() {
    rand.setSeed(rand.nextLong() + System.nanoTime());

    arrayList.clear();

    byte[] key, value;
    for (int i = 0; i < SIZE; i++) {
        key = new byte[MIN_KEY_LEN + rand.nextInt(KEY_LEN_BOUND - MIN_KEY_LEN)];
        value = new byte[rand.nextInt(VALUE_LEN_BOUND)];
        rand.nextBytes(key);
        rand.nextBytes(value);
        KeyValuePair pair = new KeyValuePair(key, value);
        array[i] = pair;
        arrayList.add(pair);
    }
    arraysArrayList = Arrays.asList(Arrays.copyOf(array, array.length));
}
 
/**
 * Setup with direct executors, small payloads and the default flow-control window.
 */
@Setup(Level.Trial)
public void setup() throws Exception {
  super.setup(ExecutorType.DIRECT,
      ExecutorType.DIRECT,
      MessageSize.SMALL,
      MessageSize.SMALL,
      FlowWindowSize.MEDIUM,
      ChannelType.NIO,
      maxConcurrentStreams,
      channelCount);
  callCounter = new AtomicLong();
  completed = new AtomicBoolean();
  record = new AtomicBoolean();
  latch = startStreamingCalls(maxConcurrentStreams, callCounter, record, completed, 1);
}
 
@Setup(Level.Trial)
public void setup() {
    final HttpResponseStatus status = status(statusCode);
    final Buffer responseBuffer = PREFER_DIRECT_ALLOCATOR.newBuffer(100);
    HTTP_1_1.writeTo(responseBuffer);
    responseBuffer.writeByte(SP);
    status.writeTo(responseBuffer);
    responseBuffer.writeShort(CRLF_SHORT);
    responseBuffer.writeBytes("content-length: 0".getBytes(US_ASCII));
    responseBuffer.writeShort(CRLF_SHORT);
    responseBuffer.writeShort(CRLF_SHORT);
    responseByteBuf = toByteBuf(responseBuffer.slice());

    channel = new EmbeddedChannel(new HttpResponseDecoder(new ArrayDeque<>(),
            getByteBufAllocator(DEFAULT_ALLOCATOR), DefaultHttpHeadersFactory.INSTANCE, 8192, 8192));
}
 
@Setup(Level.Trial)
public final void setup() {
  SpanExporter[] exporter = new SpanExporter[exporterCount];
  Arrays.fill(exporter, new NoopSpanExporter());
  this.exporter = MultiSpanExporter.create(Arrays.asList(exporter));

  TestSpanData[] spans = new TestSpanData[spanCount];
  for (int i = 0; i < spans.length; i++) {
    spans[i] =
        TestSpanData.newBuilder()
            .setTraceId(new TraceId(1, 1))
            .setSpanId(new SpanId(1))
            .setName("noop")
            .setKind(Span.Kind.CLIENT)
            .setStartEpochNanos(1)
            .setStatus(Status.OK)
            .setEndEpochNanos(2)
            .setHasEnded(true)
            .build();
  }
  this.spans = Arrays.<SpanData>asList(spans);
}
 
@Setup(Level.Iteration)
public final void setup() throws Exception {
    ByteBufAllocator allocator = new PooledByteBufAllocator(true);
    initEngines(allocator);
    initHandshakeBuffers();

    wrapDstBuffer = allocateBuffer(clientEngine.getSession().getPacketBufferSize() << 2);
    wrapSrcBuffer = allocateBuffer(messageSize);

    byte[] bytes = new byte[messageSize];
    PlatformDependent.threadLocalRandom().nextBytes(bytes);
    wrapSrcBuffer.put(bytes);
    wrapSrcBuffer.flip();

    // Complete the initial TLS handshake.
    if (!doHandshake()) {
        throw new IllegalStateException();
    }
    doSetup();
}
 
源代码7 项目: spring-init   文件: LazyBenchmarkIT.java
@Setup(Level.Trial)
public void start() throws Exception {
	if (sample != Sample.demo) {
		setProfiles(sample.toString());
	}
	super.before();
}
 
源代码8 项目: headlong   文件: MeasureFunction.java
@Setup(Level.Trial)
public void setUp() {
    f = new Function("sam(bytes,bool,uint256[])");
    args = Tuple.of(
            Strings.decode("dave", Strings.UTF_8),
            true,
            new BigInteger[] { BigInteger.ONE, BigInteger.valueOf(2), BigInteger.valueOf(3) }
    );
}
 
源代码9 项目: 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();
  }
}
 
源代码10 项目: hadoop-ozone   文件: BenchMarkSCM.java
@TearDown(Level.Trial)
public static void tearDown() {
  try {
    lock.lock();
    if (scm != null) {
      scm.stop();
      scm.join();
      scm = null;
      FileUtil.fullyDelete(new File(testDir));
    }
  } finally {
    lock.unlock();
  }
}
 
@Setup(Level.Trial)
public void setup() {
    payloadBody = DEFAULT_RO_ALLOCATOR.fromAscii("Internal Server Error payload body for response");
    metaData = newResponseMetaData(HTTP_1_1, INTERNAL_SERVER_ERROR, INSTANCE.newHeaders())
            .addHeader(CONTENT_LENGTH, newAsciiString(Integer.toString(payloadBody.readableBytes())))
            .addHeader(CONTENT_TYPE, TEXT_PLAIN)
            .addHeader(newAsciiString("X-Custom-Header-Name"), newAsciiString("X-Custom-Header-Value"));

    channel = new EmbeddedChannel(new HttpResponseEncoder(new ArrayDeque<>(), 256, 256));
}
 
@Setup(Level.Trial)
public void prepareTestData() {
    testData = new KafkaEventMessage[bufferSize];
    int i = 0;
    while (i < bufferSize) {
        testData[i++] = message(0, i, i + 1);
        testData[i++] = message(1, i, i + 1);
        testData[i++] = message(2, i, i + 1);
        testData[i++] = message(3, i, i + 1);
    }
}
 
@Setup(Level.Iteration)
public void setup() {
    data = new byte[dataSize];
    cbos = new ConnectableBufferOutputStream(PREFER_HEAP_ALLOCATOR);
    publisher = cbos.connect();
    // Don't remove this, JMH somehow provides a default which break everything
    subscription = null;
}
 
/**
 * Stop the server and client channels.
 */
@Override
@TearDown(Level.Trial)
public void teardown() throws Exception {
  Thread.sleep(5000);
  super.teardown();
}
 
/**
 * Stop the running calls then stop the server and client channels.
 */
@Override
@TearDown(Level.Trial)
public void teardown() throws Exception {
  completed.set(true);
  if (!latch.await(5, TimeUnit.SECONDS)) {
    System.err.println("Failed to shutdown all calls.");
  }
  super.teardown();
}
 
/**
 * Stop the running calls then stop the server and client channels.
 */
@Override
@TearDown(Level.Trial)
public void teardown() throws Exception {
  completed.set(true);
  Thread.sleep(5000);
  super.teardown();
}
 
源代码17 项目: avro-util   文件: FastAvroSerdesBenchmark.java
@Setup(Level.Trial)
public void prepare() throws Exception {
  // generate avro record and bytes data
  generatedRecord = (GenericData.Record) generator.generate(properties);
  serializedBytes = serializeGeneratedRecord(generatedRecord);

  serializer = new AvroGenericSerializer(benchmarkSchema);
  fastSerializer = new AvroGenericSerializer(new FastGenericDatumWriter<>(benchmarkSchema));
  deserializer = new GenericDatumReader<>(benchmarkSchema);
  fastDeserializer = new FastGenericDatumReader<>(benchmarkSchema);
}
 
/**
 * Stop the running calls then stop the server and client channels.
 */
@Override
@TearDown(Level.Trial)
public void teardown() throws Exception {
  completed.set(true);
  if (!latch.await(5, TimeUnit.SECONDS)) {
    logger.warning("Failed to shutdown all calls.");
  }
  super.teardown();
}
 
/**
 * 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());
  }
}
 
源代码20 项目: commons-geometry   文件: CirclePerformance.java
/** Set up the instance for the benchmark. */
@Setup(Level.Iteration)
public void setup() {
    final Circle circle = randomCircle(RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP));

    tree = circle.toTree(getSegments());
}
 
源代码21 项目: sdn-rx   文件: Benchmarks.java
@Setup(Level.Iteration)
public void prepareTestData() throws IOException {
	try (BufferedReader moviesReader = new BufferedReader(
		new InputStreamReader(this.getClass().getResourceAsStream("/movies.cypher")));
		Session session = driver.session()) {
		String moviesCypher = moviesReader.lines().collect(Collectors.joining(" "));
		session.run("CREATE INDEX ON :Movie(title)");
		session.run("MATCH (n) DETACH DELETE n");
		session.run(moviesCypher);
	}
}
 
源代码22 项目: presto   文件: BenchmarkSpatialJoin.java
@Setup(Level.Invocation)
public void createPointsTable()
{
    // Generate random points within the approximate bounding box of the US polygon:
    //  POLYGON ((-124 27, -65 27, -65 49, -124 49, -124 27))
    queryRunner.execute(format("CREATE TABLE memory.default.points AS " +
            "SELECT 'p' || cast(elem AS VARCHAR) as name, xMin + (xMax - xMin) * random() as longitude, yMin + (yMax - yMin) * random() as latitude " +
            "FROM (SELECT -124 AS xMin, -65 AS xMax, 27 AS yMin, 49 AS yMax) " +
            "CROSS JOIN UNNEST(sequence(1, %s)) AS t(elem)", pointCount));
}
 
源代码23 项目: presto   文件: BenchmarkSpatialJoin.java
@TearDown(Level.Invocation)
public void dropPointsTable()
{
    queryRunner.inTransaction(queryRunner.getDefaultSession(), transactionSession -> {
        Metadata metadata = queryRunner.getMetadata();
        Optional<TableHandle> tableHandle = metadata.getTableHandle(transactionSession, QualifiedObjectName.valueOf("memory.default.points"));
        assertTrue(tableHandle.isPresent(), "Table memory.default.points does not exist");
        metadata.dropTable(transactionSession, tableHandle.get());
        return null;
    });
}
 
源代码24 项目: spring-init   文件: SlimBenchmarkIT.java
@Setup(Level.Trial)
public void start() throws Exception {
	if (sample != Sample.demo) {
		setProfiles(sample.toString(), "slim");
	}
	else {
		setProfiles("slim");
	}
	super.before();
}
 
@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);

}
 
源代码26 项目: mtcnn-java   文件: MtcnnServiceBenchmark.java
@Setup(Level.Trial)
public void setUp() throws IOException {
	Nd4j.ENFORCE_NUMERICAL_STABILITY = false;

	mtcnnService = new MtcnnService(30, 0.709, new double[] { 0.6, 0.7, 0.7 });

	image = new Java2DNativeImageLoader().asMatrix(
			new DefaultResourceLoader().getResource("classpath:/VikiMaxiAdi.jpg").getInputStream())
			.get(point(0), all(), all(), all()).dup();
}
 
源代码27 项目: spring-init   文件: LauncherState.java
@Setup(Level.Invocation)
public void start() throws Exception {
	System.setProperty("server.port", "0");
	System.setProperty("spring.jmx.enabled", "false");
	System.setProperty("spring.config.location",
			"file:./src/main/resources/application.properties");
	System.setProperty("spring.main.logStartupInfo", "false");
	for (Object key : this.args.keySet()) {
		System.setProperty(key.toString(), this.args.getProperty(key.toString()));
	}
}
 
源代码28 项目: netty-4.1.22   文件: AsciiStringBenchmark.java
@Setup(Level.Trial)
public void setup() {
    byte[] bytes = new byte[size];
    random.nextBytes(bytes);
    asciiString = new AsciiString(bytes, false);
    string = new String(bytes, CharsetUtil.US_ASCII);
}
 
@Setup(Level.Trial)
public void setup() {
    final int removalStride = 5;
    availableEvents = new ArrayList<>(ops);
    mixedEvents = new ArrayList<>(ops);
    for (int i = 1; i <= ops; ++i) {
        if (i % removalStride == 0) {
            mixedEvents.add(new DefaultServiceDiscovererEvent<>(createUnresolved("127.0.0." + (i - 1), 0), false));
        } else {
            mixedEvents.add(new DefaultServiceDiscovererEvent<>(createUnresolved("127.0.0." + i, 0), true));
        }
        availableEvents.add(new DefaultServiceDiscovererEvent<>(createUnresolved("127.0.0." + i, 0), true));
    }
}
 
源代码30 项目: netty-4.1.22   文件: SslEngineHandshakeBenchmark.java
@Setup(Level.Iteration)
public void setup() {
    allocator = new PooledByteBufAllocator(true);
    // Init an engine one time and create the buffers needed for an handshake so we can use them in the benchmark
    initEngines(allocator);
    initHandshakeBuffers();
    destroyEngines();
}