proxygen
SSLCacheTest.cpp File Reference
#include <folly/io/async/EventBase.h>
#include <gflags/gflags.h>
#include <iostream>
#include <thread>
#include <folly/io/async/AsyncSSLSocket.h>
#include <folly/io/async/AsyncSocket.h>
#include <vector>

Go to the source code of this file.

Classes

class  ClientRunner
 
class  SSLCacheClient
 

Functions

 DEFINE_int32 (clients, 1,"Number of simulated SSL clients")
 
 DEFINE_int32 (threads, 1,"Number of threads to spread clients across")
 
 DEFINE_int32 (requests, 2,"Total number of requests per client")
 
 DEFINE_int32 (port, 9423,"Server port")
 
 DEFINE_bool (sticky, false,"A given client sends all reqs to one ""(random) server")
 
 DEFINE_bool (global, false,"All clients in a thread use the same SSL session")
 
 DEFINE_bool (handshakes, false,"Force 100% handshakes")
 
int main (int argc, char *argv[])
 

Variables

string f_servers [10]
 
int f_num_servers = 0
 
int tnum = 0
 

Function Documentation

DEFINE_bool ( sticky  ,
false  ,
"A given client sends all reqs to one ""(random) server"   
)
DEFINE_bool ( global  ,
false  ,
"All clients in a thread use the same SSL session"   
)
DEFINE_bool ( handshakes  ,
false  ,
"Force 100% handshakes"   
)
DEFINE_int32 ( clients  ,
,
"Number of simulated SSL clients"   
)
DEFINE_int32 ( threads  ,
,
"Number of threads to spread clients across"   
)
DEFINE_int32 ( requests  ,
,
"Total number of requests per client"   
)
DEFINE_int32 ( port  ,
9423  ,
"Server port"   
)
int main ( int  argc,
char *  argv[] 
)

Definition at line 94 of file SSLCacheTest.cpp.

References f_num_servers, f_servers, ClientRunner::hits, i, ClientRunner::miss, ClientRunner::reqs, ClientRunner::run(), string, folly::pushmi::detail::t, threads, and folly::detail::distributed_mutex::time().

95 {
96  gflags::SetUsageMessage(std::string("\n\n"
97 "usage: sslcachetest [options] -c <clients> -t <threads> servers\n"
98 ));
99  gflags::ParseCommandLineFlags(&argc, &argv, true);
100  int reqs = 0;
101  int hits = 0;
102  int miss = 0;
103  struct timeval start;
104  struct timeval end;
105  struct timeval result;
106 
107  srand((unsigned int)time(nullptr));
108 
109  for (int i = 1; i < argc; i++) {
111  }
112  if (f_num_servers == 0) {
113  cout << "require at least one server\n";
114  return 1;
115  }
116 
117  gettimeofday(&start, nullptr);
118  if (FLAGS_threads == 1) {
119  ClientRunner r;
120  r.run();
121  gettimeofday(&end, nullptr);
122  reqs = r.reqs;
123  hits = r.hits;
124  miss = r.miss;
125  }
126  else {
127  std::vector<ClientRunner> clients;
128  std::vector<std::thread> threads;
129  for (int t = 0; t < FLAGS_threads; t++) {
130  threads.emplace_back([&] {
131  clients[t].run();
132  });
133  }
134  for (auto& thr: threads) {
135  thr.join();
136  }
137  gettimeofday(&end, nullptr);
138 
139  for (const auto& client: clients) {
140  reqs += client.reqs;
141  hits += client.hits;
142  miss += client.miss;
143  }
144  }
145 
146  timersub(&end, &start, &result);
147 
148  cout << "Requests: " << reqs << endl;
149  cout << "Handshakes: " << miss << endl;
150  cout << "Resumes: " << hits << endl;
151  cout << "Runtime(ms): " << result.tv_sec << "." << result.tv_usec / 1000 <<
152  endl;
153 
154  cout << "ops/sec: " << (reqs * 1.0) /
155  ((double)result.tv_sec * 1.0 + (double)result.tv_usec / 1000000.0) << endl;
156 
157  return 0;
158 }
string f_servers[10]
int f_num_servers
std::vector< std::thread::id > threads
char ** argv
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
auto start
const char * string
Definition: Conv.cpp:212
std::chrono::nanoseconds time()

Variable Documentation

int f_num_servers = 0

Definition at line 37 of file SSLCacheTest.cpp.

Referenced by main(), and SSLCacheClient::start().

string f_servers[10]

Definition at line 36 of file SSLCacheTest.cpp.

Referenced by main(), and SSLCacheClient::start().

int tnum = 0

Definition at line 38 of file SSLCacheTest.cpp.