1 64 65 package com.jcorporate.expresso.ext.controller; 66 67 import com.jcorporate.expresso.core.registry.ExpressoThread; 68 import com.jcorporate.expresso.ext.dbobj.PerfTestResult; 69 import com.jcorporate.expresso.ext.dbobj.PerfTests; 70 71 import java.util.Enumeration ; 72 import java.util.Vector ; 73 74 75 81 public class RunTestThread 82 extends ExpressoThread { 83 private Vector setsToRun = null; 84 private int repeats = 1; 85 private PerfTestResult setResults = new PerfTestResult(); 86 private int myNumber = 0; 87 private String dbName = "default"; 88 89 public RunTestThread() { 90 super(); 91 } 92 93 public void setTests(Vector newSet) { 94 setsToRun = newSet; 95 } 96 97 public PerfTestResult getResults() { 98 return setResults; 99 } 100 101 public void setRepeats(int newRepeats) { 102 repeats = newRepeats; 103 } 104 105 public void setThreadNumber(int newNumber) { 106 myNumber = newNumber; 107 } 108 109 public int getThreadNumber() { 110 return myNumber; 111 } 112 113 public void setDBName(String newDBName) { 114 dbName = newDBName; 115 } 116 117 public void run() { 118 super.run(); 119 String currentSessionId = null; 120 PerfTestResult overallResult = new PerfTestResult(); 121 122 try { 123 System.out.println("Thread " + myNumber + " running tests " + 124 repeats + " time(s)"); 125 126 for (int i = 1; i <= repeats; i++) { 127 String currentSet = null; 128 129 for (Enumeration pse = setsToRun.elements(); 130 pse.hasMoreElements();) { 131 currentSet = (String ) pse.nextElement(); 132 System.out.println("Thread " + myNumber + 133 " running test set " + currentSet + 134 ", repitition " + i); 135 136 PerfTestResult oneResult = PerfTests.runSet(dbName, 137 currentSet, 138 currentSessionId); 139 140 if (oneResult.getSessionId() != null) { 141 currentSessionId = oneResult.getSessionId(); 142 System.out.println("Logged in, session id '" + 143 currentSessionId + "'"); 144 } 145 146 setResults.add(oneResult); 147 yield(); 148 } 149 } 150 151 152 System.gc(); 153 } catch (Exception ee) { 154 System.out.println("Thread " + myNumber + " threw exception"); 155 ee.printStackTrace(System.out); 156 } 157 } 158 159 } 160 161 162 | Popular Tags |