Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <unistd.h> |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 3 | #include <sys/time.h> |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 4 | #include <protocol/TBinaryProtocol.h> |
| 5 | #include <transport/TBufferedTransport.h> |
| 6 | #include <transport/TSocket.h> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 7 | |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 8 | #include <boost/shared_ptr.hpp> |
| 9 | #include "ThriftTest.h" |
| 10 | |
| 11 | using namespace boost; |
| 12 | using namespace std; |
| 13 | using namespace facebook::thrift; |
| 14 | using namespace facebook::thrift::protocol; |
| 15 | using namespace facebook::thrift::transport; |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 16 | using namespace thrift::test; |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 17 | |
| 18 | //extern uint32_t g_socket_syscalls; |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 19 | |
| 20 | // Current time, microseconds since the epoch |
| 21 | uint64_t now() |
| 22 | { |
| 23 | long long ret; |
| 24 | struct timeval tv; |
| 25 | |
| 26 | gettimeofday(&tv, NULL); |
| 27 | ret = tv.tv_sec; |
| 28 | ret = ret*1000*1000 + tv.tv_usec; |
| 29 | return ret; |
| 30 | } |
| 31 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 32 | int main(int argc, char** argv) { |
| 33 | string host = "localhost"; |
| 34 | int port = 9090; |
| 35 | int numTests = 1; |
| 36 | |
| 37 | if (argc > 1) { |
| 38 | host = argv[1]; |
| 39 | } |
| 40 | if (argc > 2) { |
| 41 | port = atoi(argv[2]); |
| 42 | } |
| 43 | if (argc > 3) { |
| 44 | numTests = atoi(argv[3]); |
| 45 | } |
| 46 | |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 47 | shared_ptr<TSocket> socket(new TSocket(host, port)); |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 48 | shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket)); |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 49 | shared_ptr<TBinaryProtocol> binaryProtocol(new TBinaryProtocol()); |
| 50 | ThriftTestClient testClient(bufferedSocket, binaryProtocol); |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 51 | |
| 52 | uint64_t time_min = 0; |
| 53 | uint64_t time_max = 0; |
| 54 | uint64_t time_tot = 0; |
| 55 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 56 | int test = 0; |
| 57 | for (test = 0; test < numTests; ++test) { |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 58 | |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 59 | try { |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 60 | bufferedSocket->open(); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 61 | } catch (TTransportException& ttx) { |
| 62 | printf("Connect failed: %s\n", ttx.getMessage().c_str()); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 63 | continue; |
| 64 | } |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * CONNECT TEST |
| 68 | */ |
| 69 | printf("Test #%d, connect %s:%d\n", test+1, host.c_str(), port); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 70 | |
| 71 | uint64_t start = now(); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * VOID TEST |
| 75 | */ |
| 76 | printf("testVoid()"); |
| 77 | testClient.testVoid(); |
| 78 | printf(" = void\n"); |
| 79 | |
| 80 | /** |
| 81 | * STRING TEST |
| 82 | */ |
| 83 | printf("testString(\"Test\")"); |
| 84 | string s = testClient.testString("Test"); |
| 85 | printf(" = \"%s\"\n", s.c_str()); |
| 86 | |
| 87 | /** |
| 88 | * BYTE TEST |
| 89 | */ |
| 90 | printf("testByte(1)"); |
| 91 | uint8_t u8 = testClient.testByte(1); |
| 92 | printf(" = %d\n", (int)u8); |
Mark Slee | 6e53644 | 2006-06-30 18:28:50 +0000 | [diff] [blame] | 93 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 94 | /** |
| 95 | * I32 TEST |
| 96 | */ |
| 97 | printf("testI32(-1)"); |
| 98 | int32_t i32 = testClient.testI32(-1); |
| 99 | printf(" = %d\n", i32); |
| 100 | |
| 101 | /** |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 102 | * I64 TEST |
| 103 | */ |
| 104 | printf("testI64(-34359738368)"); |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 105 | int64_t i64 = testClient.testI64(-34359738368LL); |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 106 | printf(" = %ld\n", i64); |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * DOUBLE TEST |
| 110 | */ |
| 111 | printf("testDouble(-5.2098523)"); |
| 112 | double dub = testClient.testDouble(-5.2098523); |
| 113 | printf(" = %lf\n", dub); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * STRUCT TEST |
| 117 | */ |
Mark Slee | 6e53644 | 2006-06-30 18:28:50 +0000 | [diff] [blame] | 118 | printf("testStruct({\"Zero\", 1, -3, -5})"); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 119 | Xtruct out; |
| 120 | out.string_thing = "Zero"; |
| 121 | out.byte_thing = 1; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 122 | out.i32_thing = -3; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 123 | out.i64_thing = -5; |
| 124 | Xtruct in = testClient.testStruct(out); |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 125 | printf(" = {\"%s\", %d, %d, %ld}\n", |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 126 | in.string_thing.c_str(), |
| 127 | (int)in.byte_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 128 | in.i32_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 129 | in.i64_thing); |
| 130 | |
| 131 | /** |
| 132 | * NESTED STRUCT TEST |
| 133 | */ |
Mark Slee | 6e53644 | 2006-06-30 18:28:50 +0000 | [diff] [blame] | 134 | printf("testNest({1, {\"Zero\", 1, -3, -5}), 5}"); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 135 | Xtruct2 out2; |
| 136 | out2.byte_thing = 1; |
| 137 | out2.struct_thing = out; |
| 138 | out2.i32_thing = 5; |
| 139 | Xtruct2 in2 = testClient.testNest(out2); |
| 140 | in = in2.struct_thing; |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 141 | printf(" = {%d, {\"%s\", %d, %d, %ld}, %d}\n", |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 142 | in2.byte_thing, |
| 143 | in.string_thing.c_str(), |
| 144 | (int)in.byte_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 145 | in.i32_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 146 | in.i64_thing, |
| 147 | in2.i32_thing); |
| 148 | |
| 149 | /** |
| 150 | * MAP TEST |
| 151 | */ |
| 152 | map<int32_t,int32_t> mapout; |
| 153 | for (int32_t i = 0; i < 5; ++i) { |
| 154 | mapout.insert(make_pair(i, i-10)); |
| 155 | } |
| 156 | printf("testMap({"); |
| 157 | map<int32_t, int32_t>::const_iterator m_iter; |
| 158 | bool first = true; |
| 159 | for (m_iter = mapout.begin(); m_iter != mapout.end(); ++m_iter) { |
| 160 | if (first) { |
| 161 | first = false; |
| 162 | } else { |
| 163 | printf(", "); |
| 164 | } |
| 165 | printf("%d => %d", m_iter->first, m_iter->second); |
| 166 | } |
| 167 | printf("})"); |
| 168 | map<int32_t,int32_t> mapin = testClient.testMap(mapout); |
| 169 | printf(" = {"); |
| 170 | first = true; |
| 171 | for (m_iter = mapin.begin(); m_iter != mapin.end(); ++m_iter) { |
| 172 | if (first) { |
| 173 | first = false; |
| 174 | } else { |
| 175 | printf(", "); |
| 176 | } |
| 177 | printf("%d => %d", m_iter->first, m_iter->second); |
| 178 | } |
| 179 | printf("}\n"); |
| 180 | |
| 181 | /** |
| 182 | * SET TEST |
| 183 | */ |
| 184 | set<int32_t> setout; |
| 185 | for (int32_t i = -2; i < 3; ++i) { |
| 186 | setout.insert(i); |
| 187 | } |
| 188 | printf("testSet({"); |
| 189 | set<int32_t>::const_iterator s_iter; |
| 190 | first = true; |
| 191 | for (s_iter = setout.begin(); s_iter != setout.end(); ++s_iter) { |
| 192 | if (first) { |
| 193 | first = false; |
| 194 | } else { |
| 195 | printf(", "); |
| 196 | } |
| 197 | printf("%d", *s_iter); |
| 198 | } |
| 199 | printf("})"); |
| 200 | set<int32_t> setin = testClient.testSet(setout); |
| 201 | printf(" = {"); |
| 202 | first = true; |
| 203 | for (s_iter = setin.begin(); s_iter != setin.end(); ++s_iter) { |
| 204 | if (first) { |
| 205 | first = false; |
| 206 | } else { |
| 207 | printf(", "); |
| 208 | } |
| 209 | printf("%d", *s_iter); |
| 210 | } |
| 211 | printf("}\n"); |
| 212 | |
| 213 | /** |
| 214 | * LIST TEST |
| 215 | */ |
Mark Slee | b9acf98 | 2006-10-10 01:57:32 +0000 | [diff] [blame^] | 216 | vector<int32_t> listout; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 217 | for (int32_t i = -2; i < 3; ++i) { |
| 218 | listout.push_back(i); |
| 219 | } |
| 220 | printf("testList({"); |
Mark Slee | b9acf98 | 2006-10-10 01:57:32 +0000 | [diff] [blame^] | 221 | vector<int32_t>::const_iterator l_iter; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 222 | first = true; |
| 223 | for (l_iter = listout.begin(); l_iter != listout.end(); ++l_iter) { |
| 224 | if (first) { |
| 225 | first = false; |
| 226 | } else { |
| 227 | printf(", "); |
| 228 | } |
| 229 | printf("%d", *l_iter); |
| 230 | } |
| 231 | printf("})"); |
Mark Slee | b9acf98 | 2006-10-10 01:57:32 +0000 | [diff] [blame^] | 232 | vector<int32_t> listin = testClient.testList(listout); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 233 | printf(" = {"); |
| 234 | first = true; |
| 235 | for (l_iter = listin.begin(); l_iter != listin.end(); ++l_iter) { |
| 236 | if (first) { |
| 237 | first = false; |
| 238 | } else { |
| 239 | printf(", "); |
| 240 | } |
| 241 | printf("%d", *l_iter); |
| 242 | } |
| 243 | printf("}\n"); |
| 244 | |
| 245 | /** |
| 246 | * ENUM TEST |
| 247 | */ |
| 248 | printf("testEnum(ONE)"); |
| 249 | Numberz ret = testClient.testEnum(ONE); |
| 250 | printf(" = %d\n", ret); |
| 251 | |
| 252 | printf("testEnum(TWO)"); |
| 253 | ret = testClient.testEnum(TWO); |
| 254 | printf(" = %d\n", ret); |
| 255 | |
| 256 | printf("testEnum(THREE)"); |
| 257 | ret = testClient.testEnum(THREE); |
| 258 | printf(" = %d\n", ret); |
| 259 | |
| 260 | printf("testEnum(FIVE)"); |
| 261 | ret = testClient.testEnum(FIVE); |
| 262 | printf(" = %d\n", ret); |
| 263 | |
| 264 | printf("testEnum(EIGHT)"); |
| 265 | ret = testClient.testEnum(EIGHT); |
| 266 | printf(" = %d\n", ret); |
| 267 | |
| 268 | /** |
| 269 | * TYPEDEF TEST |
| 270 | */ |
| 271 | printf("testTypedef(309858235082523)"); |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 272 | UserId uid = testClient.testTypedef(309858235082523LL); |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 273 | printf(" = %ld\n", uid); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 274 | |
| 275 | /** |
| 276 | * NESTED MAP TEST |
| 277 | */ |
| 278 | printf("testMapMap(1)"); |
| 279 | map<int32_t, map<int32_t, int32_t> > mm = testClient.testMapMap(1); |
| 280 | printf(" = {"); |
| 281 | map<int32_t, map<int32_t, int32_t> >::const_iterator mi; |
| 282 | for (mi = mm.begin(); mi != mm.end(); ++mi) { |
| 283 | printf("%d => {", mi->first); |
| 284 | map<int32_t, int32_t>::const_iterator mi2; |
| 285 | for (mi2 = mi->second.begin(); mi2 != mi->second.end(); ++mi2) { |
| 286 | printf("%d => %d, ", mi2->first, mi2->second); |
| 287 | } |
| 288 | printf("}, "); |
| 289 | } |
| 290 | printf("}\n"); |
| 291 | |
| 292 | /** |
| 293 | * INSANITY TEST |
| 294 | */ |
| 295 | Insanity insane; |
| 296 | insane.userMap.insert(make_pair(FIVE, 5000)); |
| 297 | Xtruct truck; |
| 298 | truck.string_thing = "Truck"; |
| 299 | truck.byte_thing = 8; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 300 | truck.i32_thing = 8; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 301 | truck.i64_thing = 8; |
| 302 | insane.xtructs.push_back(truck); |
| 303 | printf("testInsanity()"); |
| 304 | map<UserId, map<Numberz,Insanity> > whoa = testClient.testInsanity(insane); |
| 305 | printf(" = {"); |
| 306 | map<UserId, map<Numberz,Insanity> >::const_iterator i_iter; |
| 307 | for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) { |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 308 | printf("%ld => {", i_iter->first); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 309 | map<Numberz,Insanity>::const_iterator i2_iter; |
| 310 | for (i2_iter = i_iter->second.begin(); |
| 311 | i2_iter != i_iter->second.end(); |
| 312 | ++i2_iter) { |
| 313 | printf("%d => {", i2_iter->first); |
| 314 | map<Numberz, UserId> userMap = i2_iter->second.userMap; |
| 315 | map<Numberz, UserId>::const_iterator um; |
| 316 | printf("{"); |
| 317 | for (um = userMap.begin(); um != userMap.end(); ++um) { |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 318 | printf("%d => %ld, ", um->first, um->second); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 319 | } |
| 320 | printf("}, "); |
| 321 | |
Mark Slee | b9acf98 | 2006-10-10 01:57:32 +0000 | [diff] [blame^] | 322 | vector<Xtruct> xtructs = i2_iter->second.xtructs; |
| 323 | vector<Xtruct>::const_iterator x; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 324 | printf("{"); |
| 325 | for (x = xtructs.begin(); x != xtructs.end(); ++x) { |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 326 | printf("{\"%s\", %d, %d, %ld}, ", |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 327 | x->string_thing.c_str(), |
| 328 | (int)x->byte_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 329 | x->i32_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 330 | x->i64_thing); |
| 331 | } |
| 332 | printf("}"); |
| 333 | |
| 334 | printf("}, "); |
| 335 | } |
| 336 | printf("}, "); |
| 337 | } |
| 338 | printf("}\n"); |
| 339 | |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 340 | /* test exception */ |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 341 | |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 342 | try { |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 343 | printf("testClient.testException(\"Xception\") =>"); |
| 344 | testClient.testException("Xception"); |
| 345 | printf(" void\nFAILURE\n"); |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 346 | |
| 347 | } catch(Xception& e) { |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 348 | printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str()); |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 349 | } |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 350 | |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 351 | try { |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 352 | printf("testClient.testException(\"success\") =>"); |
| 353 | testClient.testException("success"); |
| 354 | printf(" void\n"); |
| 355 | } catch(...) { |
| 356 | printf(" exception\nFAILURE\n"); |
| 357 | } |
| 358 | |
| 359 | /* test multi exception */ |
| 360 | |
| 361 | try { |
| 362 | printf("testClient.testMultiException(\"Xception\", \"test 1\") =>"); |
| 363 | Xtruct result = testClient.testMultiException("Xception", "test 1"); |
| 364 | printf(" result\nFAILURE\n"); |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 365 | } catch(Xception& e) { |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 366 | printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str()); |
| 367 | } |
| 368 | |
| 369 | try { |
| 370 | printf("testClient.testMultiException(\"Xception2\", \"test 2\") =>"); |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 371 | Xtruct result = testClient.testMultiException("Xception2", "test 2"); |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 372 | printf(" result\nFAILURE\n"); |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 373 | |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 374 | } catch(Xception2& e) { |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 375 | printf(" {%u, {\"%s\"}}\n", e.errorCode, e.struct_thing.string_thing.c_str()); |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 376 | } |
| 377 | |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 378 | try { |
| 379 | printf("testClient.testMultiException(\"success\", \"test 3\") =>"); |
| 380 | Xtruct result = testClient.testMultiException("success", "test 3"); |
| 381 | printf(" {{\"%s\"}}\n", result.string_thing.c_str()); |
| 382 | } catch(...) { |
| 383 | printf(" exception\nFAILURE\n"); |
| 384 | } |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 385 | |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 386 | uint64_t stop = now(); |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 387 | uint64_t tot = stop-start; |
| 388 | |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 389 | printf("Total time: %lu us\n", stop-start); |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 390 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 391 | time_tot += tot; |
| 392 | if (time_min == 0 || tot < time_min) { |
| 393 | time_min = tot; |
| 394 | } |
| 395 | if (tot > time_max) { |
| 396 | time_max = tot; |
| 397 | } |
| 398 | |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 399 | bufferedSocket->close(); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 400 | } |
| 401 | |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 402 | // printf("\nSocket syscalls: %u", g_socket_syscalls); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 403 | printf("\nAll tests done.\n"); |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 404 | |
| 405 | uint64_t time_avg = time_tot / numTests; |
| 406 | |
| 407 | printf("Min time: %lu us\n", time_min); |
| 408 | printf("Max time: %lu us\n", time_max); |
| 409 | printf("Avg time: %lu us\n", time_avg); |
| 410 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 411 | return 0; |
| 412 | } |