1 26 27 package org.objectweb.benchmark.ws.latency; 28 29 import org.objectweb.benchmark.util.ResultPrinter; 31 import org.apache.axis.client.Call; 32 import org.apache.axis.client.Service; 33 import org.apache.axis.encoding.XMLType; 34 35 36 43 public class Client 44 { 45 51 52 private int nb_step; 53 54 55 private int nb_step_invocation; 56 57 58 private int step_start; 59 60 61 private String result_file; 62 63 64 private String host; 65 66 67 private Call ping_ws = null; 68 69 75 81 public Client(String name) 82 { 83 result_file = name; 84 java.util.Properties properties = new java.util.Properties (); 85 86 try { 87 java.io.InputStream propStream = null; 88 89 propStream = getClass().getClassLoader().getResourceAsStream("benchmark.properties"); 90 properties.load(propStream); 91 92 nb_step = Integer.parseInt( properties.getProperty("step.number") ); 93 nb_step_invocation = Integer.parseInt( properties.getProperty("step.invocation.number") ); 94 step_start = Integer.parseInt( properties.getProperty("step.start") ); 95 host = properties.getProperty("com.host"); 96 } catch (Exception e) { 97 e.printStackTrace(); 98 } 99 } 100 101 107 113 118 public static void main(String [] args) 119 { 120 if (args.length != 1) 121 { 122 System.out.println("Usage: Client <dest_file>"); 123 System.exit(0); 124 } 125 126 Client c = new Client(args[0]); 127 c.run(); 128 } 129 130 133 public void run() 134 { 135 String endpoint = "http://"+host+":8080/axis/PingWS.jws"; 136 137 try { 139 Service service = new Service(); 140 ping_ws = (Call) service.createCall(); 141 142 ping_ws.setTargetEndpointAddress( new java.net.URL (endpoint) ); 143 ping_ws.setOperationName("ping"); 144 ping_ws.setReturnType( XMLType.AXIS_VOID ); 145 } catch (Exception e) { 146 e.printStackTrace(); 147 } 148 149 test(); 151 } 152 153 156 public void test() 157 { 158 Object [] params = new Object [0]; 159 160 try 162 { 163 for (int i=0; i<step_start; i++) 164 ping_ws.invoke(params); 165 } catch (Exception e) { 166 e.printStackTrace(); 167 } 168 169 System.out.println("Running WS Benchmark with " + nb_step + " step(s) of " + nb_step_invocation +" method calls."); 171 try{ 172 for(int j=0; j<nb_step; j++) 173 { 174 long timer = System.currentTimeMillis(); 175 176 for (int i=0; i<nb_step_invocation; i++) 177 ping_ws.invoke(params); 178 timer = (long) ( ( System.currentTimeMillis() - timer ) * 1000 / (float)nb_step_invocation ); 179 180 ResultPrinter p = new ResultPrinter(result_file); 182 p.write(timer); 183 p.close(); 184 } 185 }catch(Exception ex){ 186 ex.printStackTrace(); 187 } 188 } 189 } 190 191 | Popular Tags |