Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 1 | package com.facebook.thrift.test; |
| 2 | |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 3 | // Generated code |
| 4 | import thrift.test.*; |
| 5 | |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 6 | import com.facebook.thrift.transport.TSocket; |
| 7 | import com.facebook.thrift.transport.TTransportException; |
| 8 | import com.facebook.thrift.protocol.TBinaryProtocol; |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 9 | |
| 10 | import java.util.HashMap; |
| 11 | import java.util.HashSet; |
| 12 | import java.util.ArrayList; |
| 13 | |
| 14 | /** |
| 15 | * Test Java client for thrift. Essentially just a copy of the C++ version, |
| 16 | * this makes a variety of requests to enable testing for both performance and |
| 17 | * correctness of the output. |
| 18 | * |
| 19 | * @author Mark Slee <mcslee@facebook.com> |
| 20 | */ |
| 21 | public class TestClient { |
| 22 | public static void main(String [] args) { |
| 23 | try { |
| 24 | String host = "localhost"; |
| 25 | int port = 9090; |
| 26 | int numTests = 1; |
| 27 | |
| 28 | if (args.length > 0) { |
| 29 | host = args[0]; |
| 30 | } |
| 31 | if (args.length > 1) { |
| 32 | port = Integer.valueOf(args[1]); |
| 33 | } |
| 34 | if (args.length > 2) { |
| 35 | numTests = Integer.valueOf(args[2]); |
| 36 | } |
| 37 | |
| 38 | TSocket tSocket = |
| 39 | new TSocket(host, port); |
| 40 | TBinaryProtocol binaryProtocol = |
| 41 | new TBinaryProtocol(); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 42 | ThriftTest.Client testClient = |
| 43 | new ThriftTest.Client(tSocket, binaryProtocol); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 44 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 45 | long timeMin = 0; |
| 46 | long timeMax = 0; |
| 47 | long timeTot = 0; |
| 48 | |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 49 | for (int test = 0; test < numTests; ++test) { |
| 50 | |
| 51 | /** |
| 52 | * CONNECT TEST |
| 53 | */ |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 54 | System.out.println("Test #" + (test+1) + ", " + "connect " + host + ":" + port); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 55 | try { |
| 56 | tSocket.open(); |
| 57 | } catch (TTransportException ttx) { |
| 58 | System.out.println("Connect failed: " + ttx.getMessage()); |
| 59 | continue; |
| 60 | } |
| 61 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 62 | long start = System.nanoTime(); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 63 | |
| 64 | /** |
| 65 | * VOID TEST |
| 66 | */ |
| 67 | System.out.print("testVoid()"); |
| 68 | testClient.testVoid(); |
| 69 | System.out.print(" = void\n"); |
| 70 | |
| 71 | /** |
| 72 | * STRING TEST |
| 73 | */ |
| 74 | System.out.print("testString(\"Test\")"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 75 | String s = testClient.testString("Test"); |
| 76 | System.out.print(" = \"" + s + "\"\n"); |
| 77 | |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 78 | /** |
| 79 | * BYTE TEST |
| 80 | */ |
| 81 | System.out.print("testByte(1)"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 82 | byte i8 = testClient.testByte((byte)1); |
| 83 | System.out.print(" = " + i8 + "\n"); |
Mark Slee | 6e53644 | 2006-06-30 18:28:50 +0000 | [diff] [blame] | 84 | |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 85 | /** |
| 86 | * I32 TEST |
| 87 | */ |
| 88 | System.out.print("testI32(-1)"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 89 | int i32 = testClient.testI32(-1); |
| 90 | System.out.print(" = " + i32 + "\n"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 91 | |
| 92 | /** |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 93 | * I64 TEST |
| 94 | */ |
| 95 | System.out.print("testI64(-34359738368)"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 96 | long i64 = testClient.testI64(-34359738368L); |
| 97 | System.out.print(" = " + i64 + "\n"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 98 | |
| 99 | /** |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 100 | * DOUBLE TEST |
| 101 | */ |
| 102 | System.out.print("testDouble(5.325098235)"); |
| 103 | double dub = testClient.testDouble(5.325098235); |
| 104 | System.out.print(" = " + dub + "\n"); |
| 105 | |
| 106 | /** |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 107 | * STRUCT TEST |
| 108 | */ |
Mark Slee | 6e53644 | 2006-06-30 18:28:50 +0000 | [diff] [blame] | 109 | System.out.print("testStruct({\"Zero\", 1, -3, -5})"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 110 | Xtruct out = new Xtruct(); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 111 | out.string_thing = "Zero"; |
| 112 | out.byte_thing = (byte) 1; |
| 113 | out.i32_thing = -3; |
| 114 | out.i64_thing = -5; |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 115 | Xtruct in = testClient.testStruct(out); |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 116 | System.out.print(" = {" + "\"" + in.string_thing + "\", " + in.byte_thing + ", " + in.i32_thing + ", " + in.i64_thing + "}\n"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * NESTED STRUCT TEST |
| 120 | */ |
Mark Slee | 6e53644 | 2006-06-30 18:28:50 +0000 | [diff] [blame] | 121 | System.out.print("testNest({1, {\"Zero\", 1, -3, -5}), 5}"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 122 | Xtruct2 out2 = new Xtruct2(); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 123 | out2.byte_thing = (short)1; |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 124 | out2.struct_thing = out; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 125 | out2.i32_thing = 5; |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 126 | Xtruct2 in2 = testClient.testNest(out2); |
| 127 | in = in2.struct_thing; |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 128 | System.out.print(" = {" + in2.byte_thing + ", {" + "\"" + in.string_thing + "\", " + in.byte_thing + ", " + in.i32_thing + ", " + in.i64_thing + "}, " + in2.i32_thing + "}\n"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 129 | |
| 130 | /** |
| 131 | * MAP TEST |
| 132 | */ |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 133 | HashMap<Integer,Integer> mapout = new HashMap<Integer,Integer>(); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 134 | for (int i = 0; i < 5; ++i) { |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 135 | mapout.put(i, i-10); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 136 | } |
| 137 | System.out.print("testMap({"); |
| 138 | boolean first = true; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 139 | for (int key : mapout.keySet()) { |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 140 | if (first) { |
| 141 | first = false; |
| 142 | } else { |
| 143 | System.out.print(", "); |
| 144 | } |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 145 | System.out.print(key + " => " + mapout.get(key)); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 146 | } |
| 147 | System.out.print("})"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 148 | HashMap<Integer,Integer> mapin = testClient.testMap(mapout); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 149 | System.out.print(" = {"); |
| 150 | first = true; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 151 | for (int key : mapin.keySet()) { |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 152 | if (first) { |
| 153 | first = false; |
| 154 | } else { |
| 155 | System.out.print(", "); |
| 156 | } |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 157 | System.out.print(key + " => " + mapout.get(key)); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 158 | } |
| 159 | System.out.print("}\n"); |
| 160 | |
| 161 | /** |
| 162 | * SET TEST |
| 163 | */ |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 164 | HashSet<Integer> setout = new HashSet<Integer>(); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 165 | for (int i = -2; i < 3; ++i) { |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 166 | setout.add(i); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 167 | } |
| 168 | System.out.print("testSet({"); |
| 169 | first = true; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 170 | for (int elem : setout) { |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 171 | if (first) { |
| 172 | first = false; |
| 173 | } else { |
| 174 | System.out.print(", "); |
| 175 | } |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 176 | System.out.print(elem); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 177 | } |
| 178 | System.out.print("})"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 179 | HashSet<Integer> setin = testClient.testSet(setout); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 180 | System.out.print(" = {"); |
| 181 | first = true; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 182 | for (int elem : setin) { |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 183 | if (first) { |
| 184 | first = false; |
| 185 | } else { |
| 186 | System.out.print(", "); |
| 187 | } |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 188 | System.out.print(elem); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 189 | } |
| 190 | System.out.print("}\n"); |
| 191 | |
| 192 | /** |
| 193 | * LIST TEST |
| 194 | */ |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 195 | ArrayList<Integer> listout = new ArrayList<Integer>(); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 196 | for (int i = -2; i < 3; ++i) { |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 197 | listout.add(i); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 198 | } |
| 199 | System.out.print("testList({"); |
| 200 | first = true; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 201 | for (int elem : listout) { |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 202 | if (first) { |
| 203 | first = false; |
| 204 | } else { |
| 205 | System.out.print(", "); |
| 206 | } |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 207 | System.out.print(elem); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 208 | } |
| 209 | System.out.print("})"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 210 | ArrayList<Integer> listin = testClient.testList(listout); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 211 | System.out.print(" = {"); |
| 212 | first = true; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 213 | for (int elem : listin) { |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 214 | if (first) { |
| 215 | first = false; |
| 216 | } else { |
| 217 | System.out.print(", "); |
| 218 | } |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 219 | System.out.print(elem); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 220 | } |
| 221 | System.out.print("}\n"); |
| 222 | |
| 223 | /** |
| 224 | * ENUM TEST |
| 225 | */ |
| 226 | System.out.print("testEnum(ONE)"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 227 | int ret = testClient.testEnum(Numberz.ONE); |
| 228 | System.out.print(" = " + ret + "\n"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 229 | |
| 230 | System.out.print("testEnum(TWO)"); |
| 231 | ret = testClient.testEnum(Numberz.TWO); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 232 | System.out.print(" = " + ret + "\n"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 233 | |
| 234 | System.out.print("testEnum(THREE)"); |
| 235 | ret = testClient.testEnum(Numberz.THREE); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 236 | System.out.print(" = " + ret + "\n"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 237 | |
| 238 | System.out.print("testEnum(FIVE)"); |
| 239 | ret = testClient.testEnum(Numberz.FIVE); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 240 | System.out.print(" = " + ret + "\n"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 241 | |
| 242 | System.out.print("testEnum(EIGHT)"); |
| 243 | ret = testClient.testEnum(Numberz.EIGHT); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 244 | System.out.print(" = " + ret + "\n"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 245 | |
| 246 | /** |
| 247 | * TYPEDEF TEST |
| 248 | */ |
| 249 | System.out.print("testTypedef(309858235082523)"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 250 | long uid = testClient.testTypedef(309858235082523L); |
| 251 | System.out.print(" = " + uid + "\n"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 252 | |
| 253 | /** |
| 254 | * NESTED MAP TEST |
| 255 | */ |
| 256 | System.out.print("testMapMap(1)"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 257 | HashMap<Integer,HashMap<Integer,Integer>> mm = |
| 258 | testClient.testMapMap(1); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 259 | System.out.print(" = {"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 260 | for (int key : mm.keySet()) { |
| 261 | System.out.print(key + " => {"); |
| 262 | HashMap<Integer,Integer> m2 = mm.get(key); |
| 263 | for (int k2 : m2.keySet()) { |
| 264 | System.out.print(k2 + " => " + m2.get(k2) + ", "); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 265 | } |
| 266 | System.out.print("}, "); |
| 267 | } |
| 268 | System.out.print("}\n"); |
| 269 | |
| 270 | /** |
| 271 | * INSANITY TEST |
| 272 | */ |
| 273 | Insanity insane = new Insanity(); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 274 | insane.userMap.put(Numberz.FIVE, (long)5000); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 275 | Xtruct truck = new Xtruct(); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 276 | truck.string_thing = "Truck"; |
| 277 | truck.byte_thing = (byte)8; |
| 278 | truck.i32_thing = 8; |
| 279 | truck.i64_thing = 8; |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 280 | insane.xtructs.add(truck); |
| 281 | System.out.print("testInsanity()"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 282 | HashMap<Long,HashMap<Integer,Insanity>> whoa = |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 283 | testClient.testInsanity(insane); |
| 284 | System.out.print(" = {"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 285 | for (long key : whoa.keySet()) { |
| 286 | HashMap<Integer,Insanity> val = whoa.get(key); |
| 287 | System.out.print(key + " => {"); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 288 | |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 289 | for (int k2 : val.keySet()) { |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 290 | Insanity v2 = val.get(k2); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 291 | System.out.print(k2 + " => {"); |
| 292 | HashMap<Integer, Long> userMap = v2.userMap; |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 293 | System.out.print("{"); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 294 | for (int k3 : userMap.keySet()) { |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 295 | System.out.print(k3 + " => " + userMap.get(k3) + ", "); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 296 | } |
| 297 | System.out.print("}, "); |
| 298 | |
| 299 | ArrayList<Xtruct> xtructs = v2.xtructs; |
| 300 | System.out.print("{"); |
| 301 | for (Xtruct x : xtructs) { |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 302 | System.out.print("{" + "\"" + x.string_thing + "\", " + x.byte_thing + ", " + x.i32_thing + ", "+ x.i64_thing + "}, "); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 303 | } |
| 304 | System.out.print("}"); |
| 305 | |
| 306 | System.out.print("}, "); |
| 307 | } |
| 308 | System.out.print("}, "); |
| 309 | } |
| 310 | System.out.print("}\n"); |
| 311 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 312 | long stop = System.nanoTime(); |
| 313 | long tot = stop-start; |
| 314 | |
| 315 | System.out.println("Total time: " + tot/1000 + "us"); |
| 316 | |
| 317 | if (timeMin == 0 || tot < timeMin) { |
| 318 | timeMin = tot; |
| 319 | } |
| 320 | if (tot > timeMax) { |
| 321 | timeMax = tot; |
| 322 | } |
| 323 | timeTot += tot; |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 324 | |
| 325 | tSocket.close(); |
| 326 | } |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 327 | |
| 328 | long timeAvg = timeTot / numTests; |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 329 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 330 | System.out.println("Min time: " + timeMin/1000 + "us"); |
| 331 | System.out.println("Max time: " + timeMax/1000 + "us"); |
| 332 | System.out.println("Avg time: " + timeAvg/1000 + "us"); |
| 333 | |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 334 | } catch (Exception x) { |
| 335 | x.printStackTrace(); |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 336 | } |
| 337 | |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 338 | } |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame^] | 339 | |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 340 | } |