CPD Results

The following document contains the results of PMD's CPD 4.1.

Duplications

File Line
org\apache\commons\feedparser\test\DebugPerformance.java 116
org\apache\commons\feedparser\test\TestPerformance.java 122
        doTestMethod( "testDefault", TestPerformance.class, 100 );
        
    }

    public static void  doTestMethod( String name, Class clazz, int max ) throws Exception {

        Method method = clazz.getMethod( name, null );

        System.out.println( "Testing method: " + name );

        long duration = 0;
        
        for ( int i = 0; i <= max; ++i ) {

            long before = System.currentTimeMillis();
            
            method.invoke( null, null );

            if ( i == 0 )
                continue; //don't measure the first call

            long after = System.currentTimeMillis();
            duration += after-before;
            
        }

        System.out.println( "----------------" );
        System.out.println( "Total parse count: " + max );

        System.out.println( "Total duration: " + duration + "  milliseconds" );

        float totalAvgDuration = (float)duration / (float)max;

        System.out.println( "Total avg duration: " + totalAvgDuration + "  milliseconds" );

        float totalPerSecond = 1000 / totalAvgDuration;

        System.out.println( "Total per second: " + totalPerSecond );

    }

}

File Line
org\apache\commons\feedparser\test\DebugPerformance.java 42
org\apache\commons\feedparser\test\TestPerformance.java 48
    public static void testSAX() throws Exception {

        if ( parser == null ) {
            parser = SAXParserFactory.newInstance().newSAXParser();

            //need to enable SAX2 locals and namespace
            parser.getXMLReader().setFeature( "http://xml.org/sax/features/namespaces", true );
        }

         org.apache.commons.feedparser.sax.RSSFeedParser handler =
              new org.apache.commons.feedparser.sax.RSSFeedParser();

         handler.listener = new DefaultFeedParserListener() {

                 public void onChannel( FeedParserState state,
                                        String title,
                                        String link,
                                        String description ) throws FeedParserException {

//                      System.out.println( "onChannel: title: " + title );
                    
                 }

                 public void onItem( FeedParserState state,
                                     String title,
                                     String link,
                                     String description,
                                     String permalink ) throws FeedParserException {

//                     System.out.println( "onItem: title: " + title );
                    
                 }

                 public void onItemEnd() throws FeedParserException {

//                     System.out.println( "onItemEnd");

                 }

             };

        String resource = "file:/home/burton/index.rss";
        
        ResourceRequest request = ResourceRequestFactory
            .getResourceRequest( resource );

        parser.parse( request.getInputStream(), handler );

    }

    public static void testDefault() throws Exception {