1 26 27 package org.objectweb.benchmark.proactive.latency; 28 29 import org.objectweb.benchmark.util.ResultPrinter; 31 32 39 public class Client 40 { 41 47 48 private int nb_step; 49 50 51 private int nb_step_invocation; 52 53 54 private int step_start; 55 56 57 private String result_file; 58 59 60 private String host; 61 62 63 private PingItf ping = null; 64 65 71 76 public Client(String name) 77 { 78 result_file = name; 79 java.util.Properties properties = new java.util.Properties (); 80 java.io.InputStream propStream = null; 81 82 try { 83 84 propStream = getClass().getClassLoader().getResourceAsStream("benchmark.properties"); 85 properties.load(propStream); 86 87 nb_step = Integer.parseInt( properties.getProperty("step.number") ); 88 nb_step_invocation = Integer.parseInt( properties.getProperty("step.invocation.number") ); 89 step_start = Integer.parseInt( properties.getProperty("step.start") ); 90 host = properties.getProperty("com.host"); 91 } catch (Exception e) { 92 e.printStackTrace(); 93 } 94 } 95 96 102 108 113 public static void main(String [] args) 114 { 115 if (args.length != 1) 116 { 117 System.out.println("Usage: Client <dest_file>"); 118 System.exit(0); 119 } 120 121 Client c = new Client(args[0]); 122 c.run(); 123 } 124 125 128 public void run() 129 { 130 try{ 132 ping = (PingItf) org.objectweb.proactive.ProActive.lookupActive(Ping.class.getName(),"//"+host+"/hello"); 133 }catch(Exception ex){ 134 ex.printStackTrace(); 135 } 136 137 test(); 139 System.exit(0); 140 } 141 142 145 public void test() 146 { 147 try 149 { 150 for (int i=0; i<step_start; i++) 151 ping.ping(); 152 } catch (Exception e) { 153 e.printStackTrace(); 154 } 155 156 System.out.println("Running Rmi Benchmark with " + nb_step + " step(s) of " + nb_step_invocation +" method calls."); 158 try 159 { 160 for(int j=0; j<nb_step; j++) 161 { 162 long timer = System.currentTimeMillis(); 163 164 for (int i=0; i<nb_step_invocation; i++) 165 ping.ping(); 166 timer = (long) ( ( System.currentTimeMillis() - timer ) * 1000 / (float)nb_step_invocation ); 167 168 ResultPrinter p = new ResultPrinter(result_file); 170 p.write(timer); 171 p.close(); 172 } 173 }catch(Exception ex){ 174 ex.printStackTrace(); 175 } 176 } 177 } 178 | Popular Tags |