1 9 10 package org.dom4j.samples.performance; 11 12 import org.dom4j.samples.SAXDemo; 13 14 20 public abstract class PerformanceSupport extends SAXDemo { 21 22 23 protected static boolean VERBOSE = false; 24 25 26 protected static final int DEFAULT_LOOP_COUNT = 40; 27 28 29 protected String xmlFile; 30 31 public PerformanceSupport() { 32 } 33 34 public void run(String [] args) throws Exception { 35 if (args.length < 1) { 36 printUsage("<XML document URL> [<loopCount>]"); 37 return; 38 } 39 40 xmlFile = args[0]; 41 42 int loopCount = DEFAULT_LOOP_COUNT; 43 if (args.length > 1) { 44 loopCount = Integer.parseInt(args[1]); 45 } 46 47 setUp(); 48 49 Timer timer = new Timer(); 50 timer.setLoopCount(loopCount); 51 timer.setTask(createTask()); 52 timer.run(); 53 54 tearDown(); 55 } 56 57 protected void setUp() throws Exception { 58 } 59 60 protected void tearDown() throws Exception { 61 } 62 63 protected abstract Task createTask() throws Exception ; 64 } 65 66 104 | Popular Tags |