package com.eactive.eai.transformer;

import com.eactive.eai.transformer.engine.Parser;

public class ParserTest {
	
	private static void testConcat(String word1, String word2) throws Exception {
		String exp = null;
//		word1 + " " + word2 = Hello999999 JEXL999999 631ms
//		exp = "word1 + \" \" + word2";
//		concat(word1, word2) = JEXL999999Hello999999 524ms
		exp = "concat(word1, word2)";
		Parser parser = new Parser();
		parser.getJep().addFunction("concat", new ConcatFunction());
		parser.parse(exp);
		Object result = null;
		long t = System.currentTimeMillis();
		for(int i=0; i< 1000000; i++) {			
			parser.addVariable("word1", word1+i);
			parser.addVariable("word2", word2+i);
			result = parser.getValueAsObject();
		}
		System.out.println(String.format("%s = %s", exp,result) +  " " + (System.currentTimeMillis() - t) + "ms");
		
	}
	
	public static void main(String[] args) {
		try {
			testConcat("Hello", "JEXL");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
