當前位置: 首頁>>代碼示例>>Java>>正文


Java Setup類代碼示例

本文整理匯總了Java中org.openjdk.jmh.annotations.Setup的典型用法代碼示例。如果您正苦於以下問題:Java Setup類的具體用法?Java Setup怎麽用?Java Setup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Setup類屬於org.openjdk.jmh.annotations包,在下文中一共展示了Setup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setup

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setup() throws PropertyVetoException {
  dataSource = new DriverManagerDataSource();
  dataSource.setDriverClassName("com.mysql.jdbc.Driver");
  dataSource.setUrl(propertyOr("jdbcUrl", "jdbc:mysql://127.0.0.1:3306?useSSL=false"));
  dataSource.setUsername(propertyOr("username", "root"));
  dataSource.setPassword(propertyOr("password", "root"));

  JdbcTemplate delegate = new JdbcTemplate(dataSource);
  delegate.setDataSource(dataSource);

  proxy = new SenderProxy(new JdbcTemplateSender(delegate));
  proxy.onMessages(updated -> counter.addAndGet(updated.size()));

  reporter = reporter(proxy);
  batch = new BatchJdbcTemplate(delegate, reporter);
  batch.setDataSource(dataSource);

  unbatch = new JdbcTemplate(dataSource);
  unbatch.setDataSource(dataSource);
  unbatch.update(CREATE_DATABASE);
  unbatch.update(DROP_TABLE);
  unbatch.update(CREATE_TABLE);
}
 
開發者ID:tramchamploo,項目名稱:buffer-slayer,代碼行數:25,代碼來源:AbstractBatchJdbcTemplateBenchmark.java

示例2: start

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void start() {
    counter = 0;
    if (log == null) {
        System.setProperty(
                "Log4jContextSelector",
                "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
        LoggerContext context = LoggerContext.getContext();
        log = context.getLogger("Log4j2");
        log.setAdditive(false);
        ArrayList<Appender> list = new ArrayList<Appender>();
        list.addAll(log.getAppenders().values());
        for (Appender a : list) {
            log.removeAppender(a);
        }
    }
}
 
開發者ID:a-hansen,項目名稱:alog,代碼行數:18,代碼來源:AlogBenchmark.java

示例3: setup

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setup() {
	ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
	executor.schedule(
			() -> {
				System.out.println("Deoptimize: 1");
				state = 1;
			},
			25, TimeUnit.SECONDS);
	executor.schedule(
			() -> {
				System.out.println("Deoptimize :0");
				state = 0;
			},
			30, TimeUnit.SECONDS);
}
 
開發者ID:dodie,項目名稱:jvm-dynamic-optimizations-performance-test,代碼行數:17,代碼來源:Nullness.java

示例4: setup

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setup() {
  NTPUDPClient client = new NTPUDPClient();
  ZoneId zoneId = ZoneId.systemDefault();
  List<String> ntpHosts = Arrays.asList("0.pool.ntp.org", "1.pool.ntp.org", "2.pool.ntp.org", "3.pool.ntp.org");
  int pollIntvl = 8_000;

  clockWithCaching = new NTPClock(
      "cached-ntp-clock-benchmark",
      zoneId,
      ntpHosts,
      client,
      pollIntvl,
      150
  );
  clockWithoutCaching = new NTPClock(
      "uncached-ntp-clock-benchmark",
      ZoneId.systemDefault(),
      ntpHosts,
      client,
      pollIntvl,
      0
  );

  nanoTimeStart = System.nanoTime();
}
 
開發者ID:jbrisbin,項目名稱:reactor-ntp-clock,代碼行數:27,代碼來源:TimeMeasurementBenchmarks.java

示例5: setUp

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setUp() throws HekateFutureException, InterruptedException {
    nodes = new ArrayList<>(nodesCount);

    for (int i = 0; i < nodesCount; i++) {
        HekateBootstrap boot = new HekateBootstrap()
            .withNodeName("node" + i)
            .withDefaultCodec(new KryoCodecFactory<>())
            .withService(new LocalMetricsServiceFactory());

        configure(i, boot);

        Hekate node = boot.join();

        nodes.add(node);
    }

    initialize(nodes);
}
 
開發者ID:hekate-io,項目名稱:hekate,代碼行數:20,代碼來源:MultiNodeBenchmarkContext.java

示例6: setup

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup(Level.Trial)
public void setup() {
  chunkStore = new ChunkImpl(
      new MetricsAndTagStoreImpl(new InvertedIndexTagStore(1_000_000, 1_000_000), new VarBitMetricStore()), null);

  try (Stream<String> lines = Files.lines(filePath, Charset.defaultCharset())) {
    lines.forEachOrdered(line -> {
      try {
        String[] words = line.split(" ");
        String metricName = words[1];
        if (counts.containsKey(metricName)) {
          counts.put(metricName, counts.get(metricName) + 1);
        } else {
          counts.put(metricName, 1);
        }

        MetricUtils.parseAndAddOpenTsdbMetric(line, chunkStore);
      } catch (Exception e) {
      }
    });
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
開發者ID:pinterest,項目名稱:yuvi,代碼行數:25,代碼來源:OffHeapVarBitMetricStoreBuildBenchmark.java

示例7: setup

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setup() {
  server = RxNetty.createHttpServer(SERVER_PORT, new RequestHandler<ByteBuf, ByteBuf>() {
    public rx.Observable handle(HttpServerRequest<ByteBuf> request,
                                HttpServerResponse<ByteBuf> response) {
      return response.flush();
    }
  });
  server.start();
  client = new OkHttpClient();
  client.setRetryOnConnectionFailure(false);
  okFeign = Feign.builder()
      .client(new feign.okhttp.OkHttpClient(client))
      .target(FeignTestInterface.class, "http://localhost:" + SERVER_PORT);
  queryRequest = new Request.Builder()
      .url("http://localhost:" + SERVER_PORT + "/?Action=GetUser&Version=2010-05-08&limit=1")
      .build();
}
 
開發者ID:wenwu315,項目名稱:XXXX,代碼行數:19,代碼來源:RealRequestBenchmarks.java

示例8: setup

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setup() {
  feignContract = new Contract.Default();
  cachedContact = new Contract() {
    private final List<MethodMetadata> cached =
        new Default().parseAndValidatateMetadata(FeignTestInterface.class);

    public List<MethodMetadata> parseAndValidatateMetadata(Class<?> declaring) {
      return cached;
    }
  };
  fakeClient = new Client() {
    public Response execute(Request request, Request.Options options) throws IOException {
      Map<String, Collection<String>> headers = new LinkedHashMap<String, Collection<String>>();
      return Response.create(200, "ok", headers, (byte[]) null);
    }
  };
  cachedFakeFeign = Feign.builder().client(fakeClient).build();
  cachedFakeApi = cachedFakeFeign.newInstance(
      new HardCodedTarget<FeignTestInterface>(FeignTestInterface.class, "http://localhost"));
}
 
開發者ID:wenwu315,項目名稱:XXXX,代碼行數:22,代碼來源:WhatShouldWeCacheBenchmarks.java

示例9: setup

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setup() {
  NTPUDPClient client = new NTPUDPClient();
  ZoneId zoneId = ZoneId.systemDefault();
  List<String> ntpHosts = Arrays.asList("0.pool.ntp.org", "1.pool.ntp.org", "2.pool.ntp.org", "3.pool.ntp.org");
  int pollIntvl = 8_000;

  clock = new NTPClock(
      "ntp-clock-benchmark",
      zoneId,
      ntpHosts,
      client,
      pollIntvl,
      resolution
  );
}
 
開發者ID:jbrisbin,項目名稱:reactor-ntp-clock,代碼行數:17,代碼來源:NTPClockBenchmarks.java

示例10: setUp

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Override
@Setup(Level.Trial)
public void setUp() throws Exception {
    domStore = new InMemoryDOMDataStore("SINGLE_THREADED_DS_BENCHMARK", Executors.newSingleThreadExecutor());
    schemaContext = BenchmarkModel.createTestContext();
    domStore.onGlobalContextUpdated(schemaContext);
    initTestNode();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:9,代碼來源:InMemoryDataStoreWriteTransactionBenchmark.java

示例11: setup

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setup() {
    stringBuilders = new ArrayList<>(numStringBuilders);
    IntStream.range(0, numStringBuilders).forEach(
            i -> {
                stringBuilders.add(new StringBuilder());
            }
    );
}
 
開發者ID:awslabs,項目名稱:swage,代碼行數:10,代碼來源:FormatBenchmarks.java

示例12: setup

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setup() {
    this.sink = new DataConsumer();

    dataKeys = new ArrayList<>(numDataEntries);
    IntStream.range(0, numDataEntries).forEach(
            i -> {
                dataKeys.add(TypedMap.key("Key" + rand.get().nextInt(), String.class));
            }
    );
}
 
開發者ID:awslabs,項目名稱:swage,代碼行數:12,代碼來源:TypedMapBenchmarks.java

示例13: setup

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setup() {
  this.input = new ArrayList<>(size);
  for (int i = 0; i < size; i++) {
    input.add(Measurement.ofConcurrency().andThroughput(i, Math.random() * i));
  }
}
 
開發者ID:codahale,項目名稱:usl4j,代碼行數:8,代碼來源:Benchmarks.java

示例14: setUp

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setUp() throws Exception {
    final String[] params = indicesShardsReplicasNodes.split("\\|");

    int numIndices = toInt(params[0]);
    int numShards = toInt(params[1]);
    int numReplicas = toInt(params[2]);
    int numNodes = toInt(params[3]);

    strategy = Allocators.createAllocationService(Settings.builder()
            .put("cluster.routing.allocation.awareness.attributes", "tag")
            .build());

    MetaData.Builder mb = MetaData.builder();
    for (int i = 1; i <= numIndices; i++) {
        mb.put(IndexMetaData.builder("test_" + i)
                .settings(Settings.builder().put("index.version.created", Version.CURRENT))
                .numberOfShards(numShards)
                .numberOfReplicas(numReplicas)
        );
    }
    MetaData metaData = mb.build();
    RoutingTable.Builder rb = RoutingTable.builder();
    for (int i = 1; i <= numIndices; i++) {
        rb.addAsNew(metaData.index("test_" + i));
    }
    RoutingTable routingTable = rb.build();
    DiscoveryNodes.Builder nb = DiscoveryNodes.builder();
    for (int i = 1; i <= numNodes; i++) {
        nb.add(Allocators.newNode("node" + i, Collections.singletonMap("tag", "tag_" + (i % numTags))));
    }
    initialClusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
        .metaData(metaData).routingTable(routingTable).nodes
            (nb).build();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:36,代碼來源:AllocationBenchmark.java

示例15: setup

import org.openjdk.jmh.annotations.Setup; //導入依賴的package包/類
@Setup
public void setup(final Blackhole bh) {
    workerBaseline = new Worker() {
        double x;

        @Override
        public void work() {
            // do nothing
        }
    };

    workerWrong = new Worker() {
        double x;

        @Override
        public void work() {
            Math.log(x);
        }
    };

    workerRight = new Worker() {
        double x;

        @Override
        public void work() {
            bh.consume(Math.log(x));
        }
    };

}
 
開發者ID:mumudemo,項目名稱:mumu-benchmark,代碼行數:31,代碼來源:JMHSample_28_BlackholeHelpers.java


注:本文中的org.openjdk.jmh.annotations.Setup類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。