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


Java ConsoleReporter.report方法代碼示例

本文整理匯總了Java中com.codahale.metrics.ConsoleReporter.report方法的典型用法代碼示例。如果您正苦於以下問題:Java ConsoleReporter.report方法的具體用法?Java ConsoleReporter.report怎麽用?Java ConsoleReporter.report使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.codahale.metrics.ConsoleReporter的用法示例。


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

示例1: main

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public static void main(String... args) {

        MetricRegistry metricRegistry = new MetricRegistry();

        final ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS).build();

        GitHub github = Feign.builder().invocationHandlerFactory(
                new FeignOutboundMetricsDecorator(new InvocationHandlerFactory.Default(), metricRegistry))
                .decoder(new GsonDecoder()).target(GitHub.class, "https://api.github.com");

        // Fetch and print a list of the contributors to this library.
        List<Contributor> contributors = github.contributors("mwiede", "metrics-feign");
        for (Contributor contributor : contributors) {
            System.out.println(contributor.login + " (" + contributor.contributions + ")");
        }

        reporter.report();
    }
 
開發者ID:mwiede,項目名稱:metrics-feign,代碼行數:20,代碼來源:Example.java

示例2: run

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
private void run(PrintStream printStream) {
    long sleepPeriodMillis = config.getMetricsOutputPeriodSeconds() * 1000;
    ConsoleReporter consoleReporter = ConsoleReporter
            .forRegistry(metricRegistry)
            .outputTo(printStream)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
    while (true) {
        try {
            Thread.sleep(sleepPeriodMillis);
            consoleReporter.report();
        } catch (InterruptedException ignored) {
            interrupt();
            LOGGER.trace("interrupted");
            break;
        }
    }
}
 
開發者ID:vy,項目名稱:hrrs,代碼行數:20,代碼來源:MetricFileReporter.java

示例3: main

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    MetricRegistry metrics = new MetricRegistry();
    ConsoleReporter reporter = PerformanceHelper.consoleReporter(metrics);
    Timer timer = metrics.timer("allocations");

    Random random = new Random(System.nanoTime());
    int iterations = 1000000;
    MemoryPointer[] pointerArray = new MemoryPointer[iterations];

    for (int i = 0; i < pointerArray.length; i++) {
        Timer.Context watch = timer.time();
        pointerArray[i] = MemoryAllocator.allocate(random.nextInt(16384));
        watch.stop();
    }

    reporter.report();
}
 
開發者ID:jordw,項目名稱:heftydb,代碼行數:18,代碼來源:MemoryPerformance.java

示例4: main

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public static void main(String[] args) {
    MetricRegistry metrics = new MetricRegistry();
    ConsoleReporter reporter = PerformanceHelper.consoleReporter(metrics);
    Timer timer = metrics.timer("reads");
    TupleGenerator generator = new TupleGenerator();
    List<Tuple> tuples = generator.testRecords(1, 64000, 20, 16, 100);

    TupleBlock.Builder blockBuilder = new TupleBlock.Builder();
    for (Tuple tuple : tuples) {
        blockBuilder.addRecord(tuple);
    }

    TupleBlock block = blockBuilder.build();

    Random random = new Random(System.nanoTime());
    int iterations = 10000000;

    for (int i = 0; i < iterations; i++) {
        Timer.Context watch = timer.time();
        block.get(tuples.get(random.nextInt(tuples.size())).key());
        watch.stop();
    }

    reporter.report();
}
 
開發者ID:jordw,項目名稱:heftydb,代碼行數:26,代碼來源:RecordBlockPerformance.java

示例5: main

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    MetricRegistry metrics = new MetricRegistry();
    ConsoleReporter reporter = PerformanceHelper.consoleReporter(metrics);
    Timer timer = metrics.timer("writes");

    TestFileHelper.createTestDirectory();
    KeyValueGenerator keyValueGenerator = new KeyValueGenerator();
    Value value = new Value(keyValueGenerator.testValue(100));

    DBState state = ConfigGenerator.perfState();
    TableWriter tableWriter = new TableWriter(state.config(), state.paths(), state.tables(), state.snapshots(),
            state.caches(), new Metrics(state.config()));

    for (int i = 0; i < RECORD_COUNT; i++) {
        value.data().rewind();
        Timer.Context watch = timer.time();
        tableWriter.write(ByteBuffers.fromString(i + ""), value.data(), false);
        watch.stop();
    }

    reporter.report();
    tableWriter.close();

    TestFileHelper.cleanUpTestFiles();
}
 
開發者ID:jordw,項目名稱:heftydb,代碼行數:26,代碼來源:RecordWriterPerformance.java

示例6: dumpMetrics

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
@TearDown
        public void dumpMetrics() throws Exception {

            // enable when using yourkit for single runs
//            if (controller != null) {
//                controller.captureSnapshot(Controller.SNAPSHOT_WITH_HEAP);
//            }
            final MetricRegistry metrics = injector.getInstance(MetricRegistry.class);
            // make the registry available to the profiler
            metricRegistry = metrics;
            final ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics)
                    .outputTo(new PrintStream("/tmp/bench-" + directoryName + ".txt"))
                    .build();
            reporter.report();
        }
 
開發者ID:Graylog2,項目名稱:graylog-plugin-pipeline-processor,代碼行數:16,代碼來源:PipelinePerformanceBenchmarks.java

示例7: acceptVisitor

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public void acceptVisitor(ServerVisitor serverVisitor){
    //MetricRegistry to string
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintStream ps = new PrintStream(baos,false, "UTF-8");
        ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metricRegistry).outputTo(ps).build();
        consoleReporter.report();
        consoleReporter.stop();
        serverVisitor.jettyReport=new String(baos.toByteArray(), StandardCharsets.UTF_8);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:factoryfx,項目名稱:factoryfx,代碼行數:14,代碼來源:InstrumentedJettyServer.java

示例8: reportTo

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public void reportTo(PrintStream out) {
    ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(context.getMetrics())
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .convertRatesTo(TimeUnit.SECONDS)
            .filter(MetricFilter.ALL)
            .outputTo(out)
            .build();
    consoleReporter.report();
}
 
開發者ID:jshook,項目名稱:testclient,代碼行數:10,代碼來源:Result.java

示例9: main

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    JDBCBenchmark bench = new JDBCBenchmark();

    Random r = new Random();

    MetricRegistry mr = new MetricRegistry();
    Timer timer = mr.timer("shadow/pgsql/benchmark");

    System.out.println("Press any key to start.");
    // System.in.read();

    System.out.println("Looping");
    for (int i = 0; i < 50000; i++) {
        Timer.Context t = timer.time();
        bench.selectPojos();

        long duration = t.stop();
        //System.out.format("got %d pojos\n", pojos.size());
        if (i % 500 == 0) {
            System.out.format("run: %d duration: %d\n", i, duration);
        }
    }
    System.out.println("Completed press any key to quit");
    System.in.read();
    bench.close();

    ConsoleReporter report = ConsoleReporter.forRegistry(mr)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();

    report.report();
}
 
開發者ID:thheller,項目名稱:shadow-pgsql,代碼行數:34,代碼來源:JDBCBenchmark.java

示例10: main

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {

        final MetricRegistry metricRegistry = new MetricRegistry();
        final Meter meter = metricRegistry.meter("throughput");
        final ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build();
        reporter.start(1, TimeUnit.MINUTES);

        final Properties properties = new Properties();
        properties.setProperty("zookeeper.connect", "localhost:2181");
        properties.setProperty("group.id", "myclient");
        properties.setProperty("zookeeper.session.timeout.ms", "400");
        properties.setProperty("zookeeper.sync.time.ms", "200");
        properties.setProperty("auto.commit.interval.ms", "1000");
        properties.setProperty("auto.offset.reset", "smallest");
        properties.setProperty("consumer.timeout.ms", "10000");

        final ConsumerConfig consumerConfig = new ConsumerConfig(properties);

        final String topic = "csc8101";
        final int numThreads = 4;

        final ConsumerConnector consumerConnector = Consumer.createJavaConsumerConnector(consumerConfig);
        final Map<String, Integer> topicCountMap = new HashMap<>();
        topicCountMap.put(topic, numThreads);
        final Decoder<String> decoder = new StringDecoder(new VerifiableProperties());
        final Map<String, List<KafkaStream<String, String>>> streamsMap =
                consumerConnector.createMessageStreams(topicCountMap, decoder, decoder);

        final ExecutorService executorService = Executors.newFixedThreadPool(numThreads);

        for(final KafkaStream<String, String> stream : streamsMap.get(topic)) {
            final MessageHandler messageHandler = new MessageHandler();
            final RunnableConsumer runnableConsumer = new RunnableConsumer(stream, messageHandler, meter);
            executorService.submit(runnableConsumer);
        }

        executorService.shutdown();
        executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.HOURS);

        consumerConnector.shutdown();

        MessageHandler.close();

        reporter.report();
        reporter.stop();

        // we use the newer version of metrics, which shuts itself down cleanly. But...
        // kafka still uses the old one and doesn't shut it down properly,
        // leaving some metrics-meter-tick-thread lying around. So to avoid
        // java.lang.IllegalThreadStateException from mvn:exec wrapper we terminate it explicitly here
        com.yammer.metrics.Metrics.defaultRegistry().shutdown();

        // bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zkconnect localhost:2181 --group myclient
    }
 
開發者ID:jhalliday,項目名稱:csc8101,代碼行數:58,代碼來源:KafkaConsumer.java

示例11: main

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public static void main(String []args) throws ExecutionException, InterruptedException {
    InRamSim sim = new InRamSim(3);
    ConsoleReporter reporter = ConsoleReporter.forRegistry(sim.metrics)
            .convertDurationsTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();

    reporter.start(5, TimeUnit.SECONDS);
    sim.run();
    System.out.println("All done baby");
    sim.dispose();
    reporter.report();
    reporter.stop();
}
 
開發者ID:cloud-software-foundation,項目名稱:c5,代碼行數:15,代碼來源:InRamSim.java

示例12: main

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public static void main(String[] args) {
    MetricRegistry metrics = new MetricRegistry();
    ConsoleReporter reporter = PerformanceHelper.consoleReporter(metrics);
    Timer timer = metrics.timer("blockCreationTime");

    KeyValueGenerator generator = new KeyValueGenerator();
    List<Key> keys = new ArrayList<Key>();

    for (int i = 0; i < 64000; i++) {
        keys.add(new Key(generator.testKey(32, 0), i));
    }

    Collections.sort(keys);

    IndexBlock.Builder blockBuilder = new IndexBlock.Builder();

    for (Key key : keys) {
        blockBuilder.addRecord(new IndexRecord(key, 0, 128));
    }

    IndexBlock block = blockBuilder.build();
    MemoryPointer blockPointer = block.memory();

    int iterations = 10000000;

    for (int i = 0; i < iterations; i++) {
        Timer.Context watch = timer.time();
        block = new IndexBlock(new SortedByteMap(blockPointer));
        watch.stop();
    }

    reporter.report();
}
 
開發者ID:jordw,項目名稱:heftydb,代碼行數:34,代碼來源:BlockCreationPerformance.java

示例13: main

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    Random random = new Random(System.nanoTime());

    Config config = new Config.Builder().directory(TestFileHelper.TEMP_PATH).compactionStrategy
            (CompactionStrategies.SIZE_TIERED_COMPACTION_STRATEGY).tableCacheSize(512000000).indexCacheSize
            (64000000).maxWriteRate(Integer.MAX_VALUE).build();

    MetricRegistry metrics = new MetricRegistry();
    ConsoleReporter reporter = PerformanceHelper.consoleReporter(metrics);
    Timer readTimer = metrics.register("reads", new Timer(new ExponentiallyDecayingReservoir()));

    DB db = HeftyDB.open(config);

    db.compact().get();

    //Read
    for (int i = 0; i < RECORD_COUNT * 10; i++) {
        String key = random.nextInt(RECORD_COUNT) + "";
        Timer.Context watch = readTimer.time();
        db.get(ByteBuffers.fromString(key));
        watch.stop();
    }

    reporter.report();
    db.logMetrics();
    db.close();

    System.exit(0);
}
 
開發者ID:jordw,項目名稱:heftydb,代碼行數:30,代碼來源:ReadPerformance.java

示例14: main

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    MetricRegistry metrics = new MetricRegistry();
    ConsoleReporter reporter = PerformanceHelper.consoleReporter(metrics);
    Timer scanTimer = metrics.timer("scans");

    TestFileHelper.createTestDirectory();
    KeyValueGenerator keyValueGenerator = new KeyValueGenerator();
    Value value = new Value(keyValueGenerator.testValue(100));

    Config config = ConfigGenerator.defaultConfig();

    //Write
    final DB db = HeftyDB.open(config);

    for (int i = 0; i < RECORD_COUNT; i++) {
        value.data().rewind();
        db.put(ByteBuffers.fromString(i + ""), value.data());
    }

    //Scan
    Iterator<Record> iterator = db.ascendingIterator(Snapshot.MAX);

    while (iterator.hasNext()) {
        Timer.Context watch = scanTimer.time();
        iterator.next();
        watch.stop();
    }

    db.close();

    reporter.report();

    TestFileHelper.cleanUpTestFiles();
}
 
開發者ID:jordw,項目名稱:heftydb,代碼行數:35,代碼來源:ScanPerformance.java

示例15: main

import com.codahale.metrics.ConsoleReporter; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    TestFileHelper.createTestDirectory();
    TestFileHelper.cleanUpTestFiles();
    KeyValueGenerator keyValueGenerator = new KeyValueGenerator();
    ByteBuffer testValueBuffer = keyValueGenerator.testValue(100);

    Config config = new Config.Builder().directory(TestFileHelper.TEMP_PATH).memoryTableSize(16384000)
            .tableCacheSize(512000000).indexCacheSize(64000000).tableBlockSize(16384).compactionStrategy
                    (CompactionStrategies.SIZE_TIERED_COMPACTION_STRATEGY).indexBlockSize(32768).maxWriteRate
                    (Integer.MAX_VALUE).build();

    //Write
    DB db = HeftyDB.open(config);

    MetricRegistry metrics = new MetricRegistry();
    ConsoleReporter reporter = PerformanceHelper.consoleReporter(metrics);
    Timer writeTimer = metrics.timer("writes");

    for (int i = 0; i < RECORD_COUNT; i++) {
        Timer.Context watch = writeTimer.time();
        db.put(ByteBuffers.fromString(i + ""), testValueBuffer.slice());
        watch.stop();
    }

    reporter.report();
    db.close();
}
 
開發者ID:jordw,項目名稱:heftydb,代碼行數:28,代碼來源:WritePerformance.java


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