David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
Roger Meier | d3b9dca | 2011-06-24 14:01:10 +0000 | [diff] [blame] | 20 | #define __STDC_FORMAT_MACROS |
| 21 | #include <inttypes.h> |
| 22 | |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 23 | #include <iostream> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 24 | #include <unistd.h> |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 25 | #include <sys/time.h> |
Roger Meier | 49ff8b1 | 2012-04-13 09:12:31 +0000 | [diff] [blame] | 26 | #include <thrift/protocol/TBinaryProtocol.h> |
| 27 | #include <thrift/protocol/TJSONProtocol.h> |
| 28 | #include <thrift/transport/THttpClient.h> |
| 29 | #include <thrift/transport/TTransportUtils.h> |
| 30 | #include <thrift/transport/TSocket.h> |
| 31 | #include <thrift/transport/TSSLSocket.h> |
| 32 | #include <thrift/async/TEvhttpClientChannel.h> |
| 33 | #include <thrift/server/TNonblockingServer.h> // <event.h> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 34 | |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 35 | #include <boost/shared_ptr.hpp> |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 36 | #include <boost/program_options.hpp> |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 37 | #include <tr1/functional> |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 38 | |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 39 | #include "ThriftTest.h" |
| 40 | |
| 41 | using namespace boost; |
| 42 | using namespace std; |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 43 | using namespace apache::thrift; |
| 44 | using namespace apache::thrift::protocol; |
| 45 | using namespace apache::thrift::transport; |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 46 | using namespace thrift::test; |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 47 | using namespace apache::thrift::async; |
| 48 | |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 49 | //extern uint32_t g_socket_syscalls; |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 50 | |
| 51 | // Current time, microseconds since the epoch |
| 52 | uint64_t now() |
| 53 | { |
Roger Meier | 5f9614c | 2010-11-21 16:59:05 +0000 | [diff] [blame] | 54 | int64_t ret; |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 55 | struct timeval tv; |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 56 | |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 57 | gettimeofday(&tv, NULL); |
| 58 | ret = tv.tv_sec; |
| 59 | ret = ret*1000*1000 + tv.tv_usec; |
| 60 | return ret; |
| 61 | } |
| 62 | |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 63 | static void testString_clientReturn(const char* host, int port, event_base *base, TProtocolFactory* protocolFactory, ThriftTestCobClient* client) { |
Roger Meier | a8cef6e | 2011-07-17 18:55:59 +0000 | [diff] [blame] | 64 | (void) host; |
| 65 | (void) port; |
| 66 | (void) protocolFactory; |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 67 | try { |
| 68 | string s; |
| 69 | client->recv_testString(s); |
| 70 | cout << "testString: " << s << endl; |
| 71 | } catch (TException& exn) { |
| 72 | cout << "Error: " << exn.what() << endl; |
| 73 | } |
| 74 | |
| 75 | event_base_loopbreak(base); // end test |
| 76 | } |
| 77 | |
| 78 | static void testVoid_clientReturn(const char* host, int port, event_base *base, TProtocolFactory* protocolFactory, ThriftTestCobClient* client) { |
| 79 | try { |
| 80 | client->recv_testVoid(); |
| 81 | cout << "testVoid" << endl; |
| 82 | |
| 83 | // next test |
| 84 | delete client; |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 85 | boost::shared_ptr<TAsyncChannel> channel(new TEvhttpClientChannel(host, "/", host, port, base)); |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 86 | client = new ThriftTestCobClient(channel, protocolFactory); |
Roger Meier | 3faaedf | 2011-10-02 10:51:45 +0000 | [diff] [blame] | 87 | client->testString(tr1::bind(testString_clientReturn, host, port, base, protocolFactory, std::tr1::placeholders::_1), "Test"); |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 88 | } catch (TException& exn) { |
| 89 | cout << "Error: " << exn.what() << endl; |
| 90 | } |
| 91 | } |
| 92 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 93 | int main(int argc, char** argv) { |
| 94 | string host = "localhost"; |
| 95 | int port = 9090; |
| 96 | int numTests = 1; |
Bryan Duxbury | cd9aea1 | 2011-02-22 18:12:06 +0000 | [diff] [blame] | 97 | bool ssl = false; |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 98 | string transport_type = "buffered"; |
| 99 | string protocol_type = "binary"; |
| 100 | string domain_socket = ""; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 101 | |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 102 | program_options::options_description desc("Allowed options"); |
| 103 | desc.add_options() |
| 104 | ("help,h", "produce help message") |
| 105 | ("host", program_options::value<string>(&host)->default_value(host), "Host to connect") |
| 106 | ("port", program_options::value<int>(&port)->default_value(port), "Port number to connect") |
| 107 | ("domain-socket", program_options::value<string>(&domain_socket)->default_value(domain_socket), "Domain Socket (e.g. /tmp/ThriftTest.thrift), instead of host and port") |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 108 | ("transport", program_options::value<string>(&transport_type)->default_value(transport_type), "Transport: buffered, framed, http, evhttp") |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 109 | ("protocol", program_options::value<string>(&protocol_type)->default_value(protocol_type), "Protocol: binary, json") |
| 110 | ("ssl", "Encrypted Transport using SSL") |
| 111 | ("testloops,n", program_options::value<int>(&numTests)->default_value(numTests), "Number of Tests") |
| 112 | ; |
| 113 | |
| 114 | program_options::variables_map vm; |
| 115 | program_options::store(program_options::parse_command_line(argc, argv, desc), vm); |
| 116 | program_options::notify(vm); |
| 117 | |
| 118 | if (vm.count("help")) { |
| 119 | cout << desc << "\n"; |
| 120 | return 1; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 121 | } |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 122 | |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 123 | try { |
| 124 | if (!protocol_type.empty()) { |
| 125 | if (protocol_type == "binary") { |
| 126 | } else if (protocol_type == "json") { |
| 127 | } else { |
| 128 | throw invalid_argument("Unknown protocol type "+protocol_type); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | if (!transport_type.empty()) { |
| 133 | if (transport_type == "buffered") { |
| 134 | } else if (transport_type == "framed") { |
| 135 | } else if (transport_type == "http") { |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 136 | } else if (transport_type == "evhttp") { |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 137 | } else { |
| 138 | throw invalid_argument("Unknown transport type "+transport_type); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | } catch (std::exception& e) { |
| 143 | cerr << e.what() << endl; |
| 144 | cout << desc << "\n"; |
| 145 | return 1; |
| 146 | } |
| 147 | |
| 148 | if (vm.count("ssl")) { |
| 149 | ssl = true; |
| 150 | } |
| 151 | |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 152 | boost::shared_ptr<TTransport> transport; |
| 153 | boost::shared_ptr<TProtocol> protocol; |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 154 | |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 155 | boost::shared_ptr<TSocket> socket; |
| 156 | boost::shared_ptr<TSSLSocketFactory> factory; |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 157 | |
Bryan Duxbury | cd9aea1 | 2011-02-22 18:12:06 +0000 | [diff] [blame] | 158 | if (ssl) { |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 159 | factory = boost::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory()); |
Bryan Duxbury | cd9aea1 | 2011-02-22 18:12:06 +0000 | [diff] [blame] | 160 | factory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); |
| 161 | factory->loadTrustedCertificates("./trusted-ca-certificate.pem"); |
| 162 | factory->authenticate(true); |
| 163 | socket = factory->createSocket(host, port); |
| 164 | } else { |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 165 | if (domain_socket != "") { |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 166 | socket = boost::shared_ptr<TSocket>(new TSocket(domain_socket)); |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 167 | port = 0; |
| 168 | } |
| 169 | else { |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 170 | socket = boost::shared_ptr<TSocket>(new TSocket(host, port)); |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 171 | } |
Bryan Duxbury | cd9aea1 | 2011-02-22 18:12:06 +0000 | [diff] [blame] | 172 | } |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 173 | |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 174 | if (transport_type.compare("http") == 0) { |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 175 | boost::shared_ptr<TTransport> httpSocket(new THttpClient(socket, host, "/service")); |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 176 | transport = httpSocket; |
| 177 | } else if (transport_type.compare("framed") == 0){ |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 178 | boost::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket)); |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 179 | transport = framedSocket; |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 180 | } else{ |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 181 | boost::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket)); |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 182 | transport = bufferedSocket; |
| 183 | } |
| 184 | |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 185 | if (protocol_type.compare("json") == 0) { |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 186 | boost::shared_ptr<TProtocol> jsonProtocol(new TJSONProtocol(transport)); |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 187 | protocol = jsonProtocol; |
| 188 | } else{ |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 189 | boost::shared_ptr<TBinaryProtocol> binaryProtocol(new TBinaryProtocol(transport)); |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 190 | protocol = binaryProtocol; |
| 191 | } |
| 192 | |
| 193 | // Connection info |
| 194 | cout << "Connecting (" << transport_type << "/" << protocol_type << ") to: " << domain_socket; |
| 195 | if (port != 0) { |
| 196 | cout << host << ":" << port; |
| 197 | } |
| 198 | cout << endl; |
| 199 | |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 200 | if (transport_type.compare("evhttp") == 0) { |
| 201 | event_base *base = event_base_new(); |
| 202 | cout << "Libevent Version: " << event_get_version() << endl; |
| 203 | cout << "Libevent Method: " << event_base_get_method(base) << endl; |
| 204 | #if LIBEVENT_VERSION_NUMBER >= 0x02000000 |
| 205 | cout << "Libevent Features: 0x" << hex << event_base_get_features(base) << endl; |
| 206 | #endif |
| 207 | |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 208 | boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 209 | |
Roger Meier | 611f90c | 2011-12-11 22:08:51 +0000 | [diff] [blame] | 210 | boost::shared_ptr<TAsyncChannel> channel(new TEvhttpClientChannel(host.c_str(), "/", host.c_str(), port, base)); |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 211 | ThriftTestCobClient* client = new ThriftTestCobClient(channel, protocolFactory.get()); |
Roger Meier | 3faaedf | 2011-10-02 10:51:45 +0000 | [diff] [blame] | 212 | client->testVoid(tr1::bind(testVoid_clientReturn, host.c_str(), port, base, protocolFactory.get(), std::tr1::placeholders::_1)); |
Roger Meier | 7e056e7 | 2011-07-17 07:28:28 +0000 | [diff] [blame] | 213 | |
| 214 | event_base_loop(base, 0); |
| 215 | return 0; |
| 216 | } |
| 217 | |
| 218 | |
Roger Meier | ca142b0 | 2011-06-07 17:59:07 +0000 | [diff] [blame] | 219 | ThriftTestClient testClient(protocol); |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 220 | |
| 221 | uint64_t time_min = 0; |
| 222 | uint64_t time_max = 0; |
| 223 | uint64_t time_tot = 0; |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 224 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 225 | int test = 0; |
| 226 | for (test = 0; test < numTests; ++test) { |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 227 | |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 228 | try { |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 229 | transport->open(); |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 230 | } catch (TTransportException& ttx) { |
Mark Slee | b9ff32a | 2006-11-16 01:00:24 +0000 | [diff] [blame] | 231 | printf("Connect failed: %s\n", ttx.what()); |
Roger Meier | 5b1e3c7 | 2011-12-08 13:20:12 +0000 | [diff] [blame] | 232 | return 1; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 233 | } |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 234 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 235 | /** |
| 236 | * CONNECT TEST |
| 237 | */ |
| 238 | 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] | 239 | |
| 240 | uint64_t start = now(); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 241 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 242 | /** |
| 243 | * VOID TEST |
| 244 | */ |
Mark Slee | e129a2d | 2007-02-21 05:17:48 +0000 | [diff] [blame] | 245 | try { |
| 246 | printf("testVoid()"); |
| 247 | testClient.testVoid(); |
| 248 | printf(" = void\n"); |
| 249 | } catch (TApplicationException tax) { |
| 250 | printf("%s\n", tax.what()); |
| 251 | } |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 252 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 253 | /** |
| 254 | * STRING TEST |
| 255 | */ |
| 256 | printf("testString(\"Test\")"); |
Mark Slee | 1921d20 | 2007-01-24 19:43:06 +0000 | [diff] [blame] | 257 | string s; |
| 258 | testClient.testString(s, "Test"); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 259 | printf(" = \"%s\"\n", s.c_str()); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 260 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 261 | /** |
| 262 | * BYTE TEST |
| 263 | */ |
| 264 | printf("testByte(1)"); |
| 265 | uint8_t u8 = testClient.testByte(1); |
| 266 | printf(" = %d\n", (int)u8); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 267 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 268 | /** |
| 269 | * I32 TEST |
| 270 | */ |
| 271 | printf("testI32(-1)"); |
| 272 | int32_t i32 = testClient.testI32(-1); |
| 273 | printf(" = %d\n", i32); |
| 274 | |
| 275 | /** |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 276 | * I64 TEST |
| 277 | */ |
| 278 | printf("testI64(-34359738368)"); |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 279 | int64_t i64 = testClient.testI64(-34359738368LL); |
David Reiss | bc3dddb | 2007-08-22 23:20:24 +0000 | [diff] [blame] | 280 | printf(" = %"PRId64"\n", i64); |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 281 | |
| 282 | /** |
| 283 | * DOUBLE TEST |
| 284 | */ |
| 285 | printf("testDouble(-5.2098523)"); |
| 286 | double dub = testClient.testDouble(-5.2098523); |
Roger Meier | a8cef6e | 2011-07-17 18:55:59 +0000 | [diff] [blame] | 287 | printf(" = %f\n", dub); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 288 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 289 | /** |
| 290 | * STRUCT TEST |
| 291 | */ |
Mark Slee | 6e53644 | 2006-06-30 18:28:50 +0000 | [diff] [blame] | 292 | printf("testStruct({\"Zero\", 1, -3, -5})"); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 293 | Xtruct out; |
| 294 | out.string_thing = "Zero"; |
| 295 | out.byte_thing = 1; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 296 | out.i32_thing = -3; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 297 | out.i64_thing = -5; |
Mark Slee | 1921d20 | 2007-01-24 19:43:06 +0000 | [diff] [blame] | 298 | Xtruct in; |
| 299 | testClient.testStruct(in, out); |
David Reiss | bc3dddb | 2007-08-22 23:20:24 +0000 | [diff] [blame] | 300 | printf(" = {\"%s\", %d, %d, %"PRId64"}\n", |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 301 | in.string_thing.c_str(), |
| 302 | (int)in.byte_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 303 | in.i32_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 304 | in.i64_thing); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 305 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 306 | /** |
| 307 | * NESTED STRUCT TEST |
| 308 | */ |
Mark Slee | 6e53644 | 2006-06-30 18:28:50 +0000 | [diff] [blame] | 309 | printf("testNest({1, {\"Zero\", 1, -3, -5}), 5}"); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 310 | Xtruct2 out2; |
| 311 | out2.byte_thing = 1; |
| 312 | out2.struct_thing = out; |
| 313 | out2.i32_thing = 5; |
Mark Slee | 1921d20 | 2007-01-24 19:43:06 +0000 | [diff] [blame] | 314 | Xtruct2 in2; |
| 315 | testClient.testNest(in2, out2); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 316 | in = in2.struct_thing; |
David Reiss | bc3dddb | 2007-08-22 23:20:24 +0000 | [diff] [blame] | 317 | printf(" = {%d, {\"%s\", %d, %d, %"PRId64"}, %d}\n", |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 318 | in2.byte_thing, |
| 319 | in.string_thing.c_str(), |
| 320 | (int)in.byte_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 321 | in.i32_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 322 | in.i64_thing, |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 323 | in2.i32_thing); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 324 | |
| 325 | /** |
| 326 | * MAP TEST |
| 327 | */ |
| 328 | map<int32_t,int32_t> mapout; |
| 329 | for (int32_t i = 0; i < 5; ++i) { |
| 330 | mapout.insert(make_pair(i, i-10)); |
| 331 | } |
| 332 | printf("testMap({"); |
| 333 | map<int32_t, int32_t>::const_iterator m_iter; |
| 334 | bool first = true; |
| 335 | for (m_iter = mapout.begin(); m_iter != mapout.end(); ++m_iter) { |
| 336 | if (first) { |
| 337 | first = false; |
| 338 | } else { |
| 339 | printf(", "); |
| 340 | } |
| 341 | printf("%d => %d", m_iter->first, m_iter->second); |
| 342 | } |
| 343 | printf("})"); |
Mark Slee | 1921d20 | 2007-01-24 19:43:06 +0000 | [diff] [blame] | 344 | map<int32_t,int32_t> mapin; |
| 345 | testClient.testMap(mapin, mapout); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 346 | printf(" = {"); |
| 347 | first = true; |
| 348 | for (m_iter = mapin.begin(); m_iter != mapin.end(); ++m_iter) { |
| 349 | if (first) { |
| 350 | first = false; |
| 351 | } else { |
| 352 | printf(", "); |
| 353 | } |
| 354 | printf("%d => %d", m_iter->first, m_iter->second); |
| 355 | } |
| 356 | printf("}\n"); |
| 357 | |
| 358 | /** |
| 359 | * SET TEST |
| 360 | */ |
| 361 | set<int32_t> setout; |
| 362 | for (int32_t i = -2; i < 3; ++i) { |
| 363 | setout.insert(i); |
| 364 | } |
| 365 | printf("testSet({"); |
| 366 | set<int32_t>::const_iterator s_iter; |
| 367 | first = true; |
| 368 | for (s_iter = setout.begin(); s_iter != setout.end(); ++s_iter) { |
| 369 | if (first) { |
| 370 | first = false; |
| 371 | } else { |
| 372 | printf(", "); |
| 373 | } |
| 374 | printf("%d", *s_iter); |
| 375 | } |
| 376 | printf("})"); |
Mark Slee | 1921d20 | 2007-01-24 19:43:06 +0000 | [diff] [blame] | 377 | set<int32_t> setin; |
| 378 | testClient.testSet(setin, setout); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 379 | printf(" = {"); |
| 380 | first = true; |
| 381 | for (s_iter = setin.begin(); s_iter != setin.end(); ++s_iter) { |
| 382 | if (first) { |
| 383 | first = false; |
| 384 | } else { |
| 385 | printf(", "); |
| 386 | } |
| 387 | printf("%d", *s_iter); |
| 388 | } |
| 389 | printf("}\n"); |
| 390 | |
| 391 | /** |
| 392 | * LIST TEST |
| 393 | */ |
Mark Slee | b9acf98 | 2006-10-10 01:57:32 +0000 | [diff] [blame] | 394 | vector<int32_t> listout; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 395 | for (int32_t i = -2; i < 3; ++i) { |
| 396 | listout.push_back(i); |
| 397 | } |
| 398 | printf("testList({"); |
Mark Slee | b9acf98 | 2006-10-10 01:57:32 +0000 | [diff] [blame] | 399 | vector<int32_t>::const_iterator l_iter; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 400 | first = true; |
| 401 | for (l_iter = listout.begin(); l_iter != listout.end(); ++l_iter) { |
| 402 | if (first) { |
| 403 | first = false; |
| 404 | } else { |
| 405 | printf(", "); |
| 406 | } |
| 407 | printf("%d", *l_iter); |
| 408 | } |
| 409 | printf("})"); |
Mark Slee | 1921d20 | 2007-01-24 19:43:06 +0000 | [diff] [blame] | 410 | vector<int32_t> listin; |
| 411 | testClient.testList(listin, listout); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 412 | printf(" = {"); |
| 413 | first = true; |
| 414 | for (l_iter = listin.begin(); l_iter != listin.end(); ++l_iter) { |
| 415 | if (first) { |
| 416 | first = false; |
| 417 | } else { |
| 418 | printf(", "); |
| 419 | } |
| 420 | printf("%d", *l_iter); |
| 421 | } |
| 422 | printf("}\n"); |
| 423 | |
| 424 | /** |
| 425 | * ENUM TEST |
| 426 | */ |
| 427 | printf("testEnum(ONE)"); |
Bryan Duxbury | 833ae49 | 2010-09-27 17:26:02 +0000 | [diff] [blame] | 428 | Numberz::type ret = testClient.testEnum(Numberz::ONE); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 429 | printf(" = %d\n", ret); |
| 430 | |
| 431 | printf("testEnum(TWO)"); |
Bryan Duxbury | 833ae49 | 2010-09-27 17:26:02 +0000 | [diff] [blame] | 432 | ret = testClient.testEnum(Numberz::TWO); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 433 | printf(" = %d\n", ret); |
| 434 | |
| 435 | printf("testEnum(THREE)"); |
Bryan Duxbury | 833ae49 | 2010-09-27 17:26:02 +0000 | [diff] [blame] | 436 | ret = testClient.testEnum(Numberz::THREE); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 437 | printf(" = %d\n", ret); |
| 438 | |
| 439 | printf("testEnum(FIVE)"); |
Bryan Duxbury | 833ae49 | 2010-09-27 17:26:02 +0000 | [diff] [blame] | 440 | ret = testClient.testEnum(Numberz::FIVE); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 441 | printf(" = %d\n", ret); |
| 442 | |
| 443 | printf("testEnum(EIGHT)"); |
Bryan Duxbury | 833ae49 | 2010-09-27 17:26:02 +0000 | [diff] [blame] | 444 | ret = testClient.testEnum(Numberz::EIGHT); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 445 | printf(" = %d\n", ret); |
| 446 | |
| 447 | /** |
| 448 | * TYPEDEF TEST |
| 449 | */ |
| 450 | printf("testTypedef(309858235082523)"); |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 451 | UserId uid = testClient.testTypedef(309858235082523LL); |
David Reiss | bc3dddb | 2007-08-22 23:20:24 +0000 | [diff] [blame] | 452 | printf(" = %"PRId64"\n", uid); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 453 | |
| 454 | /** |
| 455 | * NESTED MAP TEST |
| 456 | */ |
| 457 | printf("testMapMap(1)"); |
Mark Slee | 1921d20 | 2007-01-24 19:43:06 +0000 | [diff] [blame] | 458 | map<int32_t, map<int32_t, int32_t> > mm; |
| 459 | testClient.testMapMap(mm, 1); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 460 | printf(" = {"); |
| 461 | map<int32_t, map<int32_t, int32_t> >::const_iterator mi; |
| 462 | for (mi = mm.begin(); mi != mm.end(); ++mi) { |
| 463 | printf("%d => {", mi->first); |
| 464 | map<int32_t, int32_t>::const_iterator mi2; |
| 465 | for (mi2 = mi->second.begin(); mi2 != mi->second.end(); ++mi2) { |
| 466 | printf("%d => %d, ", mi2->first, mi2->second); |
| 467 | } |
| 468 | printf("}, "); |
| 469 | } |
| 470 | printf("}\n"); |
| 471 | |
| 472 | /** |
| 473 | * INSANITY TEST |
| 474 | */ |
| 475 | Insanity insane; |
Bryan Duxbury | 833ae49 | 2010-09-27 17:26:02 +0000 | [diff] [blame] | 476 | insane.userMap.insert(make_pair(Numberz::FIVE, 5000)); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 477 | Xtruct truck; |
| 478 | truck.string_thing = "Truck"; |
| 479 | truck.byte_thing = 8; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 480 | truck.i32_thing = 8; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 481 | truck.i64_thing = 8; |
| 482 | insane.xtructs.push_back(truck); |
| 483 | printf("testInsanity()"); |
Bryan Duxbury | 833ae49 | 2010-09-27 17:26:02 +0000 | [diff] [blame] | 484 | map<UserId, map<Numberz::type,Insanity> > whoa; |
Mark Slee | 1921d20 | 2007-01-24 19:43:06 +0000 | [diff] [blame] | 485 | testClient.testInsanity(whoa, insane); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 486 | printf(" = {"); |
Bryan Duxbury | 833ae49 | 2010-09-27 17:26:02 +0000 | [diff] [blame] | 487 | map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 488 | for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) { |
David Reiss | bc3dddb | 2007-08-22 23:20:24 +0000 | [diff] [blame] | 489 | printf("%"PRId64" => {", i_iter->first); |
Bryan Duxbury | 833ae49 | 2010-09-27 17:26:02 +0000 | [diff] [blame] | 490 | map<Numberz::type,Insanity>::const_iterator i2_iter; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 491 | for (i2_iter = i_iter->second.begin(); |
| 492 | i2_iter != i_iter->second.end(); |
| 493 | ++i2_iter) { |
| 494 | printf("%d => {", i2_iter->first); |
Bryan Duxbury | 833ae49 | 2010-09-27 17:26:02 +0000 | [diff] [blame] | 495 | map<Numberz::type, UserId> userMap = i2_iter->second.userMap; |
| 496 | map<Numberz::type, UserId>::const_iterator um; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 497 | printf("{"); |
| 498 | for (um = userMap.begin(); um != userMap.end(); ++um) { |
David Reiss | bc3dddb | 2007-08-22 23:20:24 +0000 | [diff] [blame] | 499 | printf("%d => %"PRId64", ", um->first, um->second); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 500 | } |
| 501 | printf("}, "); |
| 502 | |
Mark Slee | b9acf98 | 2006-10-10 01:57:32 +0000 | [diff] [blame] | 503 | vector<Xtruct> xtructs = i2_iter->second.xtructs; |
| 504 | vector<Xtruct>::const_iterator x; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 505 | printf("{"); |
| 506 | for (x = xtructs.begin(); x != xtructs.end(); ++x) { |
David Reiss | bc3dddb | 2007-08-22 23:20:24 +0000 | [diff] [blame] | 507 | printf("{\"%s\", %d, %d, %"PRId64"}, ", |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 508 | x->string_thing.c_str(), |
| 509 | (int)x->byte_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 510 | x->i32_thing, |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 511 | x->i64_thing); |
| 512 | } |
| 513 | printf("}"); |
| 514 | |
| 515 | printf("}, "); |
| 516 | } |
| 517 | printf("}, "); |
| 518 | } |
| 519 | printf("}\n"); |
| 520 | |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 521 | /* test exception */ |
Mark Slee | 9577100 | 2006-06-07 06:53:25 +0000 | [diff] [blame] | 522 | |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 523 | try { |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 524 | printf("testClient.testException(\"Xception\") =>"); |
| 525 | testClient.testException("Xception"); |
| 526 | printf(" void\nFAILURE\n"); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 527 | |
Mark Slee | b9ff32a | 2006-11-16 01:00:24 +0000 | [diff] [blame] | 528 | } catch(Xception& e) { |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 529 | printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str()); |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 530 | } |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 531 | |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 532 | try { |
Roger Meier | 99b3672 | 2012-05-03 21:21:43 +0000 | [diff] [blame^] | 533 | printf("testClient.testException(\"TException\") =>"); |
| 534 | testClient.testException("TException"); |
Roger Meier | f50df7f | 2012-05-02 22:49:55 +0000 | [diff] [blame] | 535 | printf(" void\nFAILURE\n"); |
| 536 | |
| 537 | } catch(TException& e) { |
| 538 | printf(" Caught TException\n"); |
| 539 | } |
| 540 | |
| 541 | try { |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 542 | printf("testClient.testException(\"success\") =>"); |
| 543 | testClient.testException("success"); |
| 544 | printf(" void\n"); |
| 545 | } catch(...) { |
| 546 | printf(" exception\nFAILURE\n"); |
| 547 | } |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 548 | |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 549 | /* test multi exception */ |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 550 | |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 551 | try { |
| 552 | printf("testClient.testMultiException(\"Xception\", \"test 1\") =>"); |
Mark Slee | 1921d20 | 2007-01-24 19:43:06 +0000 | [diff] [blame] | 553 | Xtruct result; |
| 554 | testClient.testMultiException(result, "Xception", "test 1"); |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 555 | printf(" result\nFAILURE\n"); |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 556 | } catch(Xception& e) { |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 557 | printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str()); |
| 558 | } |
| 559 | |
| 560 | try { |
| 561 | printf("testClient.testMultiException(\"Xception2\", \"test 2\") =>"); |
Mark Slee | 1921d20 | 2007-01-24 19:43:06 +0000 | [diff] [blame] | 562 | Xtruct result; |
| 563 | testClient.testMultiException(result, "Xception2", "test 2"); |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 564 | printf(" result\nFAILURE\n"); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 565 | |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 566 | } catch(Xception2& e) { |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 567 | 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] | 568 | } |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 569 | |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 570 | try { |
| 571 | printf("testClient.testMultiException(\"success\", \"test 3\") =>"); |
Mark Slee | 1921d20 | 2007-01-24 19:43:06 +0000 | [diff] [blame] | 572 | Xtruct result; |
| 573 | testClient.testMultiException(result, "success", "test 3"); |
Marc Slemko | 71d4e47 | 2006-08-15 22:34:04 +0000 | [diff] [blame] | 574 | printf(" {{\"%s\"}}\n", result.string_thing.c_str()); |
| 575 | } catch(...) { |
| 576 | printf(" exception\nFAILURE\n"); |
| 577 | } |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 578 | |
David Reiss | c51986f | 2009-03-24 20:01:25 +0000 | [diff] [blame] | 579 | /* test oneway void */ |
David Reiss | 2ab6fe8 | 2008-02-18 02:11:44 +0000 | [diff] [blame] | 580 | { |
David Reiss | 6ce401d | 2009-03-24 20:01:58 +0000 | [diff] [blame] | 581 | printf("testClient.testOneway(3) =>"); |
| 582 | uint64_t startOneway = now(); |
| 583 | testClient.testOneway(3); |
| 584 | uint64_t elapsed = now() - startOneway; |
David Reiss | 2ab6fe8 | 2008-02-18 02:11:44 +0000 | [diff] [blame] | 585 | if (elapsed > 200 * 1000) { // 0.2 seconds |
| 586 | printf(" FAILURE - took %.2f ms\n", (double)elapsed/1000.0); |
| 587 | } else { |
| 588 | printf(" success - took %.2f ms\n", (double)elapsed/1000.0); |
| 589 | } |
| 590 | } |
| 591 | |
David Reiss | 2845b52 | 2008-02-18 02:11:52 +0000 | [diff] [blame] | 592 | /** |
David Reiss | c51986f | 2009-03-24 20:01:25 +0000 | [diff] [blame] | 593 | * redo a simple test after the oneway to make sure we aren't "off by one" -- |
| 594 | * if the server treated oneway void like normal void, this next test will |
David Reiss | 2845b52 | 2008-02-18 02:11:52 +0000 | [diff] [blame] | 595 | * fail since it will get the void confirmation rather than the correct |
| 596 | * result. In this circumstance, the client will throw the exception: |
| 597 | * |
| 598 | * TApplicationException: Wrong method namea |
| 599 | */ |
| 600 | /** |
| 601 | * I32 TEST |
| 602 | */ |
| 603 | printf("re-test testI32(-1)"); |
| 604 | i32 = testClient.testI32(-1); |
| 605 | printf(" = %d\n", i32); |
| 606 | |
| 607 | |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 608 | uint64_t stop = now(); |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 609 | uint64_t tot = stop-start; |
| 610 | |
David Reiss | bc3dddb | 2007-08-22 23:20:24 +0000 | [diff] [blame] | 611 | printf("Total time: %"PRIu64" us\n", stop-start); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 612 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 613 | time_tot += tot; |
| 614 | if (time_min == 0 || tot < time_min) { |
| 615 | time_min = tot; |
| 616 | } |
| 617 | if (tot > time_max) { |
| 618 | time_max = tot; |
| 619 | } |
| 620 | |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 621 | transport->close(); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 622 | } |
| 623 | |
Marc Slemko | 6be374b | 2006-08-04 03:16:25 +0000 | [diff] [blame] | 624 | // printf("\nSocket syscalls: %u", g_socket_syscalls); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 625 | printf("\nAll tests done.\n"); |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 626 | |
| 627 | uint64_t time_avg = time_tot / numTests; |
| 628 | |
David Reiss | bc3dddb | 2007-08-22 23:20:24 +0000 | [diff] [blame] | 629 | printf("Min time: %"PRIu64" us\n", time_min); |
| 630 | printf("Max time: %"PRIu64" us\n", time_max); |
| 631 | printf("Avg time: %"PRIu64" us\n", time_avg); |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 632 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 633 | return 0; |
| 634 | } |