<commit_before>// $Header:
/*
 * Copyright 2001-2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jmeter.monitor.model.benchmark;

import java.io.*;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

import javax.xml.transform.stream.StreamSource;

public class ParseBenchmark
{

    /**
     * 
     */
    public ParseBenchmark()
    {
        super();
    }

    public static void main(String[] args)
    {
    	if (args.length == 3){
    		int parser = 0;
    		String file = null;
    		int loops = 1000;
    		if (args[0] != null){
    			if (!args[0].equals("jaxb")){
    				parser = 1;
    			}
    		}
			if (args[1] != null){
				file = args[1];
			}
			if (args[2] != null){
				loops = Integer.parseInt(args[2]);
			}

			java.io.File infile = new java.io.File(file);
			java.io.FileInputStream fis = null;
			java.io.InputStreamReader isr = null;
			StringBuffer buf = new StringBuffer();
			try {
				fis = new java.io.FileInputStream(infile);
				isr = new java.io.InputStreamReader(fis);
				java.io.BufferedReader br = new java.io.BufferedReader(isr);
				String line = null;
				while ((line = br.readLine()) != null){
					buf.append(line);
				}
			} catch (Exception e){
				e.printStackTrace();
			}
			long start = 0;
			long end = 0;
			String contents = new String(buf.toString());
			contents.trim();
			System.out.println("start test: " + loops + " iterations");
			System.out.println("content:");
			System.out.println(contents);
			
			if (parser == 0){
				try {
					JAXBContext jxbc = 
						new org.apache.jorphan.tomcat.manager.ObjectFactory();
					Unmarshaller mar = jxbc.createUnmarshaller();
						
					start = System.currentTimeMillis();
					for (int idx=0; idx < loops; idx++){
						StreamSource ss = new StreamSource(
							new ByteArrayInputStream(contents.getBytes()));
						Object ld = mar.unmarshal(ss);
					}
					end = System.currentTimeMillis();
					System.out.println("elapsed Time: " + (end - start));
				} catch (JAXBException e){
				}<commit_msg>now that I removed the jaxb classes, I commented out the jaxb portion of the benchmark. I ran several tests comparing the custom parse to jaxb. it is basically 2x faster, since I don't validate. It's not a fair comparison obviously, but for the monitor validation isn't that crucial. <NAME><commit_after>// $Header:
/*
 * Copyright 2001-2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jmeter.monitor.model.benchmark;


public class ParseBenchmark
{

    /**
     * 
     */
    public ParseBenchmark()
    {
        super();
    }

    public static void main(String[] args)
    {
    	if (args.length == 3){
    		int parser = 0;
    		String file = null;
    		int loops = 1000;
    		if (args[0] != null){
    			if (!args[0].equals("jaxb")){
    				parser = 1;
    			}
    		}
			if (args[1] != null){
				file = args[1];
			}
			if (args[2] != null){
				loops = Integer.parseInt(args[2]);
			}

			java.io.File infile = new java.io.File(file);
			java.io.FileInputStream fis = null;
			java.io.InputStreamReader isr = null;
			StringBuffer buf = new StringBuffer();
			try {
				fis = new java.io.FileInputStream(infile);
				isr = new java.io.InputStreamReader(fis);
				java.io.BufferedReader br = new java.io.BufferedReader(isr);
				String line = null;
				while ((line = br.readLine()) != null){
					buf.append(line);
				}
			} catch (Exception e){
				e.printStackTrace();
			}
			long start = 0;
			long end = 0;
			String contents = new String(buf.toString());
			contents.trim();
			System.out.println("start test: " + loops + " iterations");
			System.out.println("content:");
			System.out.println(contents);
			
			if (parser == 0){
				/**
				try {
					JAXBContext jxbc = 
						new org.apache.jorphan.tomcat.manager.ObjectFactory();
					Unmarshaller mar = jxbc.createUnmarshaller();
						
					start = System.currentTimeMillis();
					for (int idx=0; idx < loops; idx++){
						StreamSource ss = new StreamSource(
							new ByteArrayInputStream(contents.getBytes()));
						Object ld = mar.unmarshal(ss);
					}
					end = System.currentTimeMillis();
					System.out.println("elapsed Time: " + (end - start));
				} catch (JAXBException e){
				}
				**/
{'fraction_non_alphanumeric': 0.12423398328690807, 'fraction_numerical': 0.01095636025998143, 'mean_word_length': 2.8063604240282687, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '682556', 'n_tokens_mistral': 1987, 'n_tokens_neox': 1658, 'n_words': 497}