1 9 10 package org.nfunk.jepexamples; 11 12 import java.util.*; 13 14 import org.nfunk.jep.JEP; 15 16 20 public class LargeExpressionTest { 21 public static void main(String args[]) { 22 int nEvals = 500; 23 int nVars = 1000; 24 Date start, finish; 25 String str = ""; 26 27 JEP myParser = new JEP(); 28 29 for (int i=0; i<10; i++) { 31 myParser.addVariable("v"+i, 0); 32 str += "+" + "v" + i; 33 } 34 myParser.parseExpression(str); 35 System.out.print("Evaluating with small symbol table... "); 36 start = new Date(); 37 for (int i=0; i<nEvals; i++) { 38 myParser.getValue(); 39 } 40 finish = new Date(); 41 System.out.println("done."); 42 System.out.println("Time: " + 43 (finish.getTime() - start.getTime())); 44 45 str = ""; 47 for (int i=0; i<nVars; i++) { 48 myParser.addVariable("v" + i, 0); 49 str += "+" + "v" + i; 50 } 51 myParser.parseExpression(str); 52 System.out.print("Evaluating with large symbol table... "); 53 start = new Date(); 54 for (int i=0; i<nEvals; i++) { 55 myParser.getValue(); 56 } 57 finish = new Date(); 58 System.out.println("done."); 59 System.out.println("Time: " + 60 (finish.getTime() - start.getTime())); 61 } 62 } 63 | Popular Tags |