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