public void testCache()
throws Exception
{
m_engine.saveText( "TestPage", TEST_TEXT );
StopWatch sw = new StopWatch();
System.out.println("DOM cache speed test:");
sw.start();
for( int i = 0; i < 100; i++ )
{
WikiPage page = m_engine.getPage( "TestPage" );
String pagedata = m_engine.getPureText( page );
WikiContext context = new WikiContext( m_engine, page );
MarkupParser p = m_manager.getParser( context, pagedata );
WikiDocument d = p.parse();
String html = m_manager.getHTML( context, d );
assertNotNull( "noncached got null response",html);
}
sw.stop();
System.out.println(" Nocache took "+sw);
long nocachetime = sw.getTime();
sw.reset();
sw.start();
for( int i = 0; i < 100; i++ )
{
WikiPage page = m_engine.getPage( "TestPage" );
String pagedata = m_engine.getPureText( page );
WikiContext context = new WikiContext( m_engine, page );
String html = m_manager.getHTML( context, pagedata );
assertNotNull("cached got null response",html);
}
sw.stop();
System.out.println(" Cache took "+sw);
long speedup = nocachetime / sw.getTime();
System.out.println(" Approx speedup: "+speedup+"x");
}