/*
 * XMLBench.java
 *
 * Created on February 20, 2003, 7:09 PM
 */

package XMLBench;

import java.io.*;
import java.util.*;

/**
 *
 * @author  Tienshiao Ma
 */
public class XMLBenchReaderrss {
    
    /** Creates a new instance of XMLBench */
    public XMLBenchReaderrss() {
    }
        
    private static void testReaderSetup(String s) {
        ByteArrayInputStream bin = 
            new ByteArrayInputStream(s.getBytes());
        new InputStreamReader(bin);
    }
            
    public static void runTests(String testString) {
        int iterations = 5000;
        long start;
        long stop;
        
        System.out.println("Test String is " + testString.length() + " chars.");
        
        testReaderSetup(testString);
        System.out.println("TestReaderSetup start ...");
        System.gc();
        start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            testReaderSetup(testString);
        }
        stop = System.currentTimeMillis();
        System.out.println("... TestReaderSetup end: " + (stop - start));
        
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // long example
        runTests("<?xml version=\"1.0\"?>\n" +
                 "<!DOCTYPE rss PUBLIC\n" +
                 "  \"-//Netscape Communications//DTD RSS 0.91//EN\"\n" + 
                 "  \"http://my.netscape.com/publish/formats/rss-0.91.dtd\"\n" +
                 ">\n" +
                 "<rss version=\"0.91\">\n" +
                 "  <channel>\n" + 
                 "    <title>Meerkat: An Open Wire Service</title>\n" +
                 "    <link>http://meerkat.oreillynet.com</link>\n" +
                 "    <description>\n" +
                 "      Meerkat is a Web-based syndicated content reader \n" +
                 "      providing a simple interface to RSS stories.  While\n" +
                 "      maintaining the original association of a story with\n" +
                 "      a channel, Meerkat's focus is on chronological\n" +
                 "      order -- the latest stories float to the top,\n" +
                 "      regardless of their source.\n" +
                 "    </description>\n" +
                 "    <language>en-us</language>\n" +
                 "    <image>\n" +
                 "      <title>Meerkat Powered!</title> \n" +
                 "      <url>\n" +
                 "      http://meerkat.oreillynet.com/icons/meerkat-powered.jpg\n" +
                 "      </url>\n" +
                 "      <link>http://meerkat.oreillynet.com</link> \n" +
                 "      <width>88</width> \n" +
                 "      <height>31</height> \n" +
                 "      <description>Visit Meerkat in full splendor at\n" +
                 "          meerkat.oreillynet.com...</description> \n" +
                 "    </image> \n" +
                 "    <item>\n" +
                 "      <title>MmO2 cuts jobs, to take GBP110m charge</title>\n" +
                 "      <link>http://c.moreover.com/click/here.pl?r31561327\n" +
                 "          </link>\n" +
                 "      <description>FTMarketWatch Feb 5 2002 5:05AM ET...\n" +
                 "          </description>\n" +
                 "    </item>\n" +
                 "    <item>\n" +
                 "      <title>S.E.C. Says Motorola Cant Exclude Audit\n" +
                 "          Proposal</title>\n" +
                 "      <link>http://c.moreover.com/click/here.pl?r31562096\n" +
                 "          </link>\n" +
                 "      <description>New York Times Feb 5 2002 5:17AM ET...\n" +
                 "          </description>\n" +
                 "    </item>\n" +
                 "    <item>\n" +
                 "      <title>1,900 jobs to go at mmO2</title>\n" +
                 "      <link>http://c.moreover.com/click/here.pl?r31562134\n" +
                 "          </link>\n" +
                 "      <description>ZDNet Feb 5 2002 5:18AM ET..\n" +
                 "          </description>\n" +
                 "    </item>\n" +
                 "    <item>\n" +
                 "      <title>Mobile firm cutting 1,900 jobs</title>\n" +
                 "      <link>http://c.moreover.com/click/here.pl?r31558750\n" +
                 "          </link>\n" +
                 "      <description>CNN Europe Feb 5 2002 4:30AM ET...\n" +
                 "          </description>\n" +
                 "    </item>\n" +
                 "    <item>\n" +
                 "      <title>The axe falls at mmO2</title>\n" +
                 "      <link>http://c.moreover.com/click/here.pl?r31558856\n" +
                 "          </link>\n" +
                 "      <description>The Register Feb 5 2002 4:32AM ET...\n" +
                 "          j</description>\n" +
                 "    </item>\n" +
                 "    <item>\n" +
                 "      <title>mmO2 plans to axe 1,900 jobs</title>\n" +
                 "      <link>http://c.moreover.com/click/here.pl?r31559617\n" +
                 "          </link>\n" +
                 "      <description>Evening Standard Feb 5 2002 4:42AM ET...\n" +
                 "          </description>\n" +
                 "    </item>\n" +
                 "    <item>\n" +
                 "      <title>UPDATE 2-Sohu Q4 revenues up 15 pct on wireless\n" +
                 "          services</title>\n" +
                 "      <link>http://c.moreover.com/click/here.pl?r31557811\n" +
                 "          </link>\n" +
                 "      <description>CNET Feb 5 2002 4:08AM ET...</description>\n" +
                 "    </item>\n" +
                 "  </channel>\n" +
                 "</rss>");

    }

}
