Java Code Examples for com.codahale.metrics.ConsoleReporter#report()
The following examples show how to use
com.codahale.metrics.ConsoleReporter#report() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MemoryPerformance.java From heftydb with Apache License 2.0 | 6 votes |
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(); }
Example 2
Source File: RecordBlockPerformance.java From heftydb with Apache License 2.0 | 6 votes |
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(); }
Example 3
Source File: RecordWriterPerformance.java From heftydb with Apache License 2.0 | 6 votes |
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(); }
Example 4
Source File: NodeTest.java From sofa-jraft with Apache License 2.0 | 5 votes |
@Test public void testNodeMetrics() throws Exception { final List<PeerId> peers = TestUtils.generatePeers(3); final TestCluster cluster = new TestCluster("unittest", this.dataPath, peers); for (final PeerId peer : peers) { assertTrue(cluster.start(peer.getEndpoint(), false, 300, true)); } // elect leader cluster.waitLeader(); // get leader final Node leader = cluster.getLeader(); assertNotNull(leader); assertEquals(3, leader.listPeers().size()); // apply tasks to leader this.sendTestTaskAndWait(leader); { final ByteBuffer data = ByteBuffer.wrap("no closure".getBytes()); final Task task = new Task(data, null); leader.apply(task); } cluster.ensureSame(-1); for (final Node node : cluster.getNodes()) { System.out.println("-------------" + node.getNodeId() + "-------------"); final ConsoleReporter reporter = ConsoleReporter.forRegistry(node.getNodeMetrics().getMetricRegistry()) .build(); reporter.report(); reporter.close(); System.out.println(); } // TODO check http status assertEquals(2, cluster.getFollowers().size()); cluster.stopAll(); // System.out.println(node.getNodeMetrics().getMetrics()); }
Example 5
Source File: PerformanceTestController.java From raptor with Apache License 2.0 | 5 votes |
private String getMetricReport(MetricRegistry registry) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(outputStream); ConsoleReporter reporter = ConsoleReporter.forRegistry(registry) .outputTo(ps) .build(); reporter.report(); return new String(outputStream.toByteArray()); }
Example 6
Source File: BlockCreationPerformance.java From heftydb with Apache License 2.0 | 5 votes |
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(); }
Example 7
Source File: ReadPerformance.java From heftydb with Apache License 2.0 | 5 votes |
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); }
Example 8
Source File: ScanPerformance.java From heftydb with Apache License 2.0 | 5 votes |
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(); }
Example 9
Source File: WritePerformance.java From heftydb with Apache License 2.0 | 5 votes |
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(); }
Example 10
Source File: IndexBlockPerformance.java From heftydb with Apache License 2.0 | 5 votes |
public static void main(String[] args) { MetricRegistry metrics = new MetricRegistry(); ConsoleReporter reporter = PerformanceHelper.consoleReporter(metrics); Timer timer = metrics.timer("reads"); 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(); Random random = new Random(System.nanoTime()); int iterations = 10000000; for (int i = 0; i < iterations; i++) { Timer.Context watch = timer.time(); block.get(keys.get(random.nextInt(keys.size()))); watch.stop(); } reporter.report(); }
Example 11
Source File: MediaScannerServiceTestCase.java From airsonic-advanced with GNU General Public License v3.0 | 4 votes |
/** * Tests the MediaScannerService by scanning the test media library into an empty database. */ @Test public void testScanLibrary() { Timer globalTimer = metrics.timer(MetricRegistry.name(MediaScannerServiceTestCase.class, "Timer.global")); Timer.Context globalTimerContext = globalTimer.time(); cleanupId = ScanningTestUtils.before(MusicFolderTestData.getTestMusicFolders(), settingsService, mediaScannerService); globalTimerContext.stop(); // Music Folder Music must have 3 children List<MediaFile> listeMusicChildren = mediaFileDao.getChildrenOf(MusicFolderTestData.resolveMusicFolderPath().toString()); Assert.assertEquals(3, listeMusicChildren.size()); // Music Folder Music2 must have 1 children List<MediaFile> listeMusic2Children = mediaFileDao.getChildrenOf(MusicFolderTestData.resolveMusic2FolderPath().toString()); Assert.assertEquals(1, listeMusic2Children.size()); System.out.println("--- List of all artists ---"); System.out.println("artistName#albumCount"); List<Artist> allArtists = artistDao.getAlphabetialArtists(0, Integer.MAX_VALUE, musicFolderDao.getAllMusicFolders()); allArtists.forEach(artist -> System.out.println(artist.getName() + "#" + artist.getAlbumCount())); System.out.println("--- *********************** ---"); System.out.println("--- List of all albums ---"); System.out.println("name#artist"); List<Album> allAlbums = albumDao.getAlphabeticalAlbums(0, Integer.MAX_VALUE, true, true, musicFolderDao.getAllMusicFolders()); allAlbums.forEach(album -> System.out.println(album.getName() + "#" + album.getArtist())); Assert.assertEquals(5, allAlbums.size()); System.out.println("--- *********************** ---"); List<MediaFile> listeSongs = mediaFileDao.getSongsByGenre("Baroque Instrumental", 0, Integer.MAX_VALUE, musicFolderDao.getAllMusicFolders()); Assert.assertEquals(2, listeSongs.size()); // display out metrics report ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.report(); System.out.print("End"); }
Example 12
Source File: MediaScannerServiceTestCase.java From airsonic with GNU General Public License v3.0 | 4 votes |
/** * Tests the MediaScannerService by scanning the test media library into an empty database. */ @Test public void testScanLibrary() { musicFolderDao.getAllMusicFolders().forEach(musicFolder -> musicFolderDao.deleteMusicFolder(musicFolder.getId())); MusicFolderTestData.getTestMusicFolders().forEach(musicFolderDao::createMusicFolder); settingsService.clearMusicFolderCache(); Timer globalTimer = metrics.timer(MetricRegistry.name(MediaScannerServiceTestCase.class, "Timer.global")); Timer.Context globalTimerContext = globalTimer.time(); TestCaseUtils.execScan(mediaScannerService); globalTimerContext.stop(); System.out.println("--- Report of records count per table ---"); Map<String, Integer> records = TestCaseUtils.recordsInAllTables(daoHelper); records.keySet().forEach(tableName -> System.out.println(tableName + " : " + records.get(tableName).toString())); System.out.println("--- *********************** ---"); // Music Folder Music must have 3 children List<MediaFile> listeMusicChildren = mediaFileDao.getChildrenOf(new File(MusicFolderTestData.resolveMusicFolderPath()).getPath()); Assert.assertEquals(3, listeMusicChildren.size()); // Music Folder Music2 must have 1 children List<MediaFile> listeMusic2Children = mediaFileDao.getChildrenOf(new File(MusicFolderTestData.resolveMusic2FolderPath()).getPath()); Assert.assertEquals(1, listeMusic2Children.size()); System.out.println("--- List of all artists ---"); System.out.println("artistName#albumCount"); List<Artist> allArtists = artistDao.getAlphabetialArtists(0, Integer.MAX_VALUE, musicFolderDao.getAllMusicFolders()); allArtists.forEach(artist -> System.out.println(artist.getName() + "#" + artist.getAlbumCount())); System.out.println("--- *********************** ---"); System.out.println("--- List of all albums ---"); System.out.println("name#artist"); List<Album> allAlbums = albumDao.getAlphabeticalAlbums(0, Integer.MAX_VALUE, true, true, musicFolderDao.getAllMusicFolders()); allAlbums.forEach(album -> System.out.println(album.getName() + "#" + album.getArtist())); Assert.assertEquals(5, allAlbums.size()); System.out.println("--- *********************** ---"); List<MediaFile> listeSongs = mediaFileDao.getSongsByGenre("Baroque Instrumental", 0, 0, musicFolderDao.getAllMusicFolders()); Assert.assertEquals(2, listeSongs.size()); // display out metrics report ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.report(); System.out.print("End"); }