### Question:
VerbosePageCacheTracer extends DefaultPageCacheTracer { @Override public MajorFlushEvent beginCacheFlush() { log.info( "Start whole page cache flush." ); return new PageCacheMajorFlushEvent( flushedPages.get(), flushBytesWritten.get(), clock.nanos() ); } VerbosePageCacheTracer( Log log, SystemNanoClock clock ); @Override void mappedFile( File file ); @Override void unmappedFile( File file ); @Override MajorFlushEvent beginCacheFlush(); @Override MajorFlushEvent beginFileFlush( PageSwapper swapper );  }### Answer:
@Test public void traceSinglePageCacheFlush() { VerbosePageCacheTracer tracer = createTracer(); try ( MajorFlushEvent majorFlushEvent = tracer.beginCacheFlush() ) { FlushEventOpportunity flushEventOpportunity = majorFlushEvent.flushEventOpportunity(); FlushEvent flushEvent = flushEventOpportunity.beginFlush( 1, 2, new DummyPageSwapper( "testFile", 1 ) ); flushEvent.addBytesWritten( 2 ); flushEvent.addPagesFlushed( 7 ); flushEvent.done(); } logProvider.formattedMessageMatcher().assertContains( "Start whole page cache flush." ); logProvider.formattedMessageMatcher().assertContains( "Page cache flush completed. Flushed 2B in 7 pages. Flush took: 0ns. " + "Average speed: 2bytes/ns." ); }
@Test public void evictionDoesNotInfluenceFlushNumbers() { VerbosePageCacheTracer tracer = createTracer(); try ( MajorFlushEvent majorFlushEvent = tracer.beginCacheFlush() ) { FlushEventOpportunity flushEventOpportunity = majorFlushEvent.flushEventOpportunity(); FlushEvent flushEvent = flushEventOpportunity.beginFlush( 1, 2, new DummyPageSwapper( "testFile", 1 ) ); clock.forward( 2, TimeUnit.MILLISECONDS ); try ( EvictionRunEvent evictionRunEvent = tracer.beginPageEvictions( 5 ) ) { try ( EvictionEvent evictionEvent = evictionRunEvent.beginEviction() ) { FlushEventOpportunity evictionEventOpportunity = evictionEvent.flushEventOpportunity(); FlushEvent evictionFlush = evictionEventOpportunity.beginFlush( 2, 3, new DummyPageSwapper( "evictionFile", 1 ) ); evictionFlush.addPagesFlushed( 10 ); evictionFlush.addPagesFlushed( 100 ); } } flushEvent.addBytesWritten( 2 ); flushEvent.addPagesFlushed( 7 ); flushEvent.done(); } logProvider.formattedMessageMatcher().assertContains( "Start whole page cache flush." ); logProvider.formattedMessageMatcher().assertContains( "Page cache flush completed. Flushed 2B in 7 pages. Flush took: 2ms. " + "Average speed: 0bytes/ns." ); }