Main Page | Modules | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

ab.c File Reference

#include "apr.h"
#include "apr_signal.h"
#include "apr_strings.h"
#include "apr_network_io.h"
#include "apr_file_io.h"
#include "apr_time.h"
#include "apr_getopt.h"
#include "apr_general.h"
#include "apr_lib.h"
#include "apr_portable.h"
#include "ap_release.h"
#include "apr_poll.h"
#include "apr_want.h"
#include "apr_base64.h"
#include "apr_xlate.h"

Include dependency graph for ab.c:

Go to the source code of this file.

Defines

#define AP_AB_BASEREVISION   "2.0.41-dev"
#define NOT_ASCII
#define BSD_COMP
#define APR_WANT_STRFUNC
#define AB_MAX   APR_INT64_C(0x7fffffffffffffff)
#define MAX_REQUESTS   50000
#define STATE_UNCONNECTED   0
#define STATE_CONNECTING   1
#define STATE_CONNECTED   2
#define STATE_READ   3
#define CBUFFSIZE   (2048)
#define ap_min(a, b)   ((a)<(b))?(a):(b)
#define ap_max(a, b)   ((a)>(b))?(a):(b)
#define MAX_CONCURRENCY   20000
#define CONF_FMT_STRING   "%5" APR_TIME_T_FMT " %4d %5.1f %6" APR_TIME_T_FMT " %7" APR_TIME_T_FMT "\n"
#define SANE(what, mean, median, sd)
#define CONF_FMT_STRING   "%5" APR_TIME_T_FMT " %5" APR_TIME_T_FMT "%5" APR_TIME_T_FMT "\n"

Functions

static void close_connection (struct connection *c)
static void err (char *s)
static void apr_err (char *s, apr_status_t rv)
static void write_request (struct connection *c)
static int compradre (struct data *a, struct data *b)
static int comprando (struct data *a, struct data *b)
static int compri (struct data *a, struct data *b)
static int compwait (struct data *a, struct data *b)
static void output_results (void)
static void output_html_results (void)
static void start_connect (struct connection *c)
static void read_connection (struct connection *c)
static void test (void)
static void copyright (void)
static void usage (const char *progname)
static int parse_url (char *url)
static int open_postfile (const char *pfile)
int main (int argc, const char *const argv[])

Variables

int verbosity = 0
int posting = 0
int requests = 1
int heartbeatres = 100
int concurrency = 1
int percentile = 1
int confidence = 1
int tlimit = 0
int keepalive = 0
char servername [1024]
char * hostname
char * host_field
char * path
char postfile [1024]
char * postdata
apr_size_t postlen = 0
char content_type [1024]
char * cookie
char * auth
char * hdrs
apr_port_t port
char proxyhost [1024]
int proxyport = 0
char * connecthost
apr_port_t connectport
char * gnuplot
char * csvperc
char url [1024]
char * fullurl
char * colonhost
int isproxy = 0
apr_interval_time_t aprtimeout = apr_time_from_sec(30)
int use_html = 0
const char * tablestring
const char * trstring
const char * tdstring
apr_size_t doclen = 0
long started = 0
long totalread = 0
long totalbread = 0
long totalposted = 0
long done = 0
long doneka = 0
long good = 0
long bad = 0
long epipe = 0
int err_length = 0
int err_conn = 0
int err_except = 0
int err_response = 0
apr_time_t start
apr_time_t endtime
char _request [512]
char * request = _request
apr_size_t reqlen
char buffer [8192]
int percs [] = {50, 66, 75, 80, 90, 95, 98, 99, 100}
connectioncon
datastats
apr_pool_tcntxt
apr_pollset_treadbits
apr_sockaddr_tdestsa
apr_xlate_tfrom_ascii
apr_xlate_tto_ascii


Define Documentation

#define AB_MAX   APR_INT64_C(0x7fffffffffffffff)
 

Definition at line 178 of file ab.c.

Referenced by output_html_results(), and output_results().

#define AP_AB_BASEREVISION   "2.0.41-dev"
 

Definition at line 94 of file ab.c.

Referenced by copyright(), and test().

#define ap_max a,
b   )     ((a)>(b))?(a):(b)
 

Definition at line 236 of file ab.c.

Referenced by output_html_results(), and output_results().

#define ap_min a,
b   )     ((a)<(b))?(a):(b)
 

Definition at line 235 of file ab.c.

Referenced by output_html_results(), and output_results().

#define APR_WANT_STRFUNC
 

Definition at line 134 of file ab.c.

#define BSD_COMP
 

Definition at line 119 of file ab.c.

#define CBUFFSIZE   (2048)
 

Definition at line 194 of file ab.c.

Referenced by read_connection().

#define CONF_FMT_STRING   "%5" APR_TIME_T_FMT " %5" APR_TIME_T_FMT "%5" APR_TIME_T_FMT "\n"
 

#define CONF_FMT_STRING   "%5" APR_TIME_T_FMT " %4d %5.1f %6" APR_TIME_T_FMT " %7" APR_TIME_T_FMT "\n"
 

Referenced by output_results().

#define MAX_CONCURRENCY   20000
 

Definition at line 237 of file ab.c.

Referenced by main().

#define MAX_REQUESTS   50000
 

Definition at line 184 of file ab.c.

Referenced by main().

#define NOT_ASCII
 

Definition at line 115 of file ab.c.

#define SANE what,
mean,
median,
sd   ) 
 

Value:

{ \
                double d = (double)mean - median; \
                if (d < 0) d = -d; \
                if (d > 2 * sd ) \
                    printf("ERROR: The median and mean for " what " are more than twice the standard\n" \
                           "       deviation apart. These results are NOT reliable.\n"); \
                else if (d > sd ) \
                    printf("WARNING: The median and mean for " what " are not within a normal deviation\n" \
                           "        These results are probably not that reliable.\n"); \
            }

Referenced by output_results().

#define STATE_CONNECTED   2
 

Definition at line 191 of file ab.c.

Referenced by start_connect(), and test().

#define STATE_CONNECTING   1
 

Definition at line 188 of file ab.c.

Referenced by start_connect(), and test().

#define STATE_READ   3
 

Definition at line 192 of file ab.c.

Referenced by test(), and write_request().

#define STATE_UNCONNECTED   0
 

Definition at line 187 of file ab.c.

Referenced by close_connection(), start_connect(), and test().


Function Documentation

static void apr_err char *  s,
apr_status_t  rv
[static]
 

Definition at line 342 of file ab.c.

References buf, done, and exit.

Referenced by APR_DECLARE(), apr_dir_make_recursive(), read_connection(), start_connect(), and test().

static void close_connection struct connection c  )  [static]
 

Definition at line 1256 of file ab.c.

References APR_POLL_SOCKET, apr_socket_close(), connection::aprsock, bad, connection::beginread, connection::bread, connection::connect, data::ctime, apr_pollfd_t::desc, apr_pollfd_t::desc_type, doclen, connection::done, done, connection::endwrite, err_length, connection::fd, FD_CLR, good, heartbeatres, connection::keepalive, data::read, connection::read, requests, apr_descriptor::s, connection::start, start_connect(), data::starttime, connection::state, STATE_UNCONNECTED, data::time, timedif(), and data::waittime.

Referenced by read_connection(), and write_request().

Here is the call graph for this function:

static int compradre struct data a,
struct data b
[static]
 

Definition at line 771 of file ab.c.

References data::ctime.

Referenced by output_results().

static int comprando struct data a,
struct data b
[static]
 

Definition at line 780 of file ab.c.

References data::time.

Referenced by output_results().

static int compri struct data a,
struct data b
[static]
 

Definition at line 789 of file ab.c.

References data::ctime, and data::time.

Referenced by output_results().

static int compwait struct data a,
struct data b
[static]
 

Definition at line 800 of file ab.c.

References data::waittime.

Referenced by output_results().

static void copyright void   )  [static]
 

Definition at line 1773 of file ab.c.

References AP_AB_BASEREVISION, and use_html.

Referenced by main().

static void err char *  s  )  [static]
 

Definition at line 332 of file ab.c.

References done, and exit.

int main int  argc,
const char *const   argv[]
 

Definition at line 1950 of file ab.c.

References APR_DEFAULT_CHARSET, apr_isspace, apr_pool_create, apr_signal, APR_SUCCESS, apr_getopt_t::argv, auth, concurrency, confidence, cookie, copyright(), csvperc, ctx, err, exit, from_ascii, gnuplot, hdrs, heartbeatres, apr_getopt_t::ind, isproxy, keepalive, MAX_CONCURRENCY, MAX_REQUESTS, NULL, open_postfile(), opt, parse_url(), percentile, postdata, posting, proxyhost, proxyport, r, requests, ssl_util_thread_setup(), status, strdup(), tablestring, tdstring, test(), tlimit, to_ascii, trstring, usage, use_html, and verbosity.

Here is the call graph for this function:

static int open_postfile const char *  pfile  )  [static]
 

Definition at line 1907 of file ab.c.

References APR_EINVAL, APR_ENOMEM, APR_FINFO_NORM, APR_OS_DEFAULT, APR_READ, APR_SUCCESS, errmsg(), length, NULL, postdata, postlen, and apr_finfo_t::size.

Referenced by main().

Here is the call graph for this function:

static void output_html_results void   )  [static]
 

Definition at line 1060 of file ab.c.

References AB_MAX, ap_max, ap_min, apr_time_sec, APR_TIME_T_FMT, apr_time_usec, bad, concurrency, data::ctime, doclen, done, doneka, endtime, err_conn, err_except, err_length, err_response, hostname, keepalive, path, port, posting, requests, servername, start, tablestring, tdstring, data::time, totalbread, totalposted, totalread, and trstring.

Referenced by test().

static void output_results void   )  [static]
 

Definition at line 809 of file ab.c.

References AB_MAX, ap_max, ap_min, apr_ctime(), apr_time_sec, APR_TIME_T_FMT, apr_time_usec, bad, compradre(), comprando(), compri(), compwait(), concurrency, CONF_FMT_STRING, confidence, csvperc, data::ctime, doclen, done, doneka, endtime, epipe, err_conn, err_except, err_length, err_response, exit, gnuplot, hostname, keepalive, path, percentile, percs, port, posting, requests, SANE, servername, start, data::starttime, data::time, totalbread, totalposted, totalread, void(), and data::waittime.

Referenced by test().

Here is the call graph for this function:

static int parse_url char *  url  )  [static]
 

Definition at line 1835 of file ab.c.

References APR_SUCCESS, colonhost, exit, fullurl, host_field, hostname, NULL, path, port, and scope_id.

Referenced by main().

static void read_connection struct connection c  )  [static]
 

Definition at line 1316 of file ab.c.

References apr_err(), APR_POLL_SOCKET, apr_recv(), apr_socket_close(), APR_STATUS_IS_EAGAIN, APR_STATUS_IS_EOF, APR_SUCCESS, connection::aprsock, bad, connection::beginread, connection::bread, buffer, connection::cbuff, CBUFFSIZE, connection::cbx, close_connection(), connection::connect, data::ctime, apr_pollfd_t::desc, apr_pollfd_t::desc_type, doclen, connection::done, done, doneka, connection::endwrite, err, err_except, err_length, err_response, exit, from_ascii, good, connection::gotheader, heartbeatres, inbytes_left, connection::keepalive, keepalive, connection::length, outbytes_left, r, data::read, connection::read, requests, apr_descriptor::s, s, servername, connection::start, start_connect(), data::starttime, status, strstr(), data::time, totalbread, totalread, verbosity, data::waittime, and write_request().

Referenced by test().

Here is the call graph for this function:

static void start_connect struct connection c  )  [static]
 

Definition at line 1183 of file ab.c.

References apr_connect(), apr_err(), APR_POLL_SOCKET, APR_POLLOUT, apr_pool_create, APR_SO_NONBLOCK, apr_socket_close(), apr_socket_create(), apr_socket_opt_set(), APR_STATUS_IS_EINPROGRESS, APR_SUCCESS, connection::aprsock, bad, connection::bread, connection::cbx, apr_pollfd_t::client_data, connection::ctx, apr_pollfd_t::desc, apr_pollfd_t::desc_type, err_conn, apr_sockaddr_t::family, connection::gotheader, connection::keepalive, connection::read, apr_pollfd_t::reqevents, requests, connection::rwrite, apr_descriptor::s, connection::start, started, connection::state, STATE_CONNECTED, STATE_CONNECTING, STATE_UNCONNECTED, and write_request().

Referenced by close_connection(), read_connection(), start_connect(), and test().

Here is the call graph for this function:

static void test void   )  [static]
 

Definition at line 1524 of file ab.c.

References AP_AB_BASEREVISION, apr_connect(), apr_err(), APR_POLL_SOCKET, APR_POLLERR, APR_POLLHUP, APR_POLLIN, APR_POLLNVAL, APR_POLLOUT, APR_POLLPRI, apr_socket_close(), APR_SUCCESS, apr_time_sec, APR_UNSPEC, aprtimeout, auth, bad, buff, apr_pollfd_t::client_data, colonhost, concurrency, connecthost, connectport, cookie, apr_pollfd_t::desc, apr_pollfd_t::desc_type, done, err, err_conn, err_except, exit, fullurl, hdrs, heartbeatres, host_field, hostname, inbytes_left, isproxy, keepalive, now, outbytes_left, output_html_results(), output_results(), path, port, postdata, posting, postlen, proxyhost, proxyport, read_connection(), apr_pollfd_t::reqevents, reqlen, request, requests, apr_pollfd_t::rtnevents, apr_descriptor::s, connection::socknum, start, start_connect(), connection::state, STATE_CONNECTED, STATE_CONNECTING, STATE_READ, STATE_UNCONNECTED, status, tlimit, to_ascii, use_html, verbosity, and write_request().

Here is the call graph for this function:

static void usage const char *  progname  )  [static]
 

Definition at line 1791 of file ab.c.

References exit.

static void write_request struct connection c  )  [static]
 

Definition at line 684 of file ab.c.

References APR_POLL_SOCKET, APR_POLLIN, apr_send(), apr_socket_timeout_set(), APR_STATUS_IS_EAGAIN, APR_SUCCESS, connection::aprsock, aprtimeout, apr_pollfd_t::client_data, close_connection(), connection::connect, apr_pollfd_t::desc, apr_pollfd_t::desc_type, e, connection::endwrite, epipe, posting, postlen, apr_pollfd_t::reqevents, reqlen, request, connection::rwrite, connection::rwrote, apr_descriptor::s, connection::state, STATE_READ, and totalposted.

Referenced by read_connection(), start_connect(), and test().

Here is the call graph for this function:


Variable Documentation

char _request[512]
 

Definition at line 305 of file ab.c.

apr_interval_time_t aprtimeout = apr_time_from_sec(30)
 

Definition at line 271 of file ab.c.

Referenced by test(), and write_request().

char * auth
 

Definition at line 258 of file ab.c.

Referenced by APR_OPTIONAL_FN_TYPE(), dav_method_copymove(), main(), modssl_ctx_cfg_merge(), and test().

long bad = 0
 

Definition at line 288 of file ab.c.

char buffer[8192]
 

Definition at line 310 of file ab.c.

apr_pool_t* cntxt
 

Definition at line 317 of file ab.c.

char * colonhost
 

Definition at line 269 of file ab.c.

Referenced by parse_url(), and test().

struct connection* con
 

Definition at line 315 of file ab.c.

int concurrency = 1
 

Definition at line 245 of file ab.c.

Referenced by main(), output_html_results(), output_results(), and test().

int confidence = 1
 

Definition at line 247 of file ab.c.

Referenced by main(), and output_results().

char* connecthost
 

Definition at line 264 of file ab.c.

Referenced by test().

apr_port_t connectport
 

Definition at line 265 of file ab.c.

Referenced by ap_proxy_connect_handler(), ap_proxy_ftp_handler(), and test().

char content_type[1024]
 

Definition at line 257 of file ab.c.

char* cookie
 

Definition at line 258 of file ab.c.

Referenced by add_cookie(), log_cookie(), main(), and test().

char* csvperc
 

Definition at line 267 of file ab.c.

Referenced by main(), and output_results().

apr_sockaddr_t* destsa
 

Definition at line 321 of file ab.c.

Referenced by rfc1413_connect().

apr_size_t doclen = 0
 

Definition at line 281 of file ab.c.

Referenced by close_connection(), output_html_results(), output_results(), and read_connection().

long done = 0
 

Definition at line 286 of file ab.c.

Referenced by apr_err(), close_connection(), deflate_out_filter(), err(), getsfunc_BRIGADE(), main(), output_html_results(), output_results(), parse_expr(), read_connection(), test(), and xlate_out_filter().

long doneka = 0
 

Definition at line 287 of file ab.c.

Referenced by output_html_results(), output_results(), and read_connection().

apr_time_t endtime
 

Definition at line 302 of file ab.c.

Referenced by output_html_results(), and output_results().

long epipe = 0
 

Definition at line 289 of file ab.c.

Referenced by output_results(), and write_request().

int err_conn = 0
 

Definition at line 299 of file ab.c.

Referenced by output_html_results(), output_results(), start_connect(), and test().

int err_except = 0
 

Definition at line 299 of file ab.c.

Referenced by output_html_results(), output_results(), read_connection(), and test().

int err_length = 0
 

Definition at line 299 of file ab.c.

Referenced by close_connection(), output_html_results(), output_results(), and read_connection().

int err_response = 0
 

Definition at line 300 of file ab.c.

Referenced by output_html_results(), output_results(), and read_connection().

apr_xlate_t* from_ascii
 

Definition at line 324 of file ab.c.

Referenced by main(), and read_connection().

char* fullurl
 

Definition at line 269 of file ab.c.

Referenced by parse_url(), and test().

char* gnuplot
 

Definition at line 266 of file ab.c.

Referenced by main(), and output_results().

long good = 0
 

Definition at line 288 of file ab.c.

Referenced by check_speling(), close_connection(), and read_connection().

char * hdrs
 

Definition at line 258 of file ab.c.

Referenced by AP_DECLARE(), emit_head(), log_script(), lookup_header(), main(), parse_accept_headers(), set_neg_headers(), and test().

int heartbeatres = 100
 

Definition at line 244 of file ab.c.

Referenced by close_connection(), main(), read_connection(), and test().

char* host_field
 

Definition at line 252 of file ab.c.

Referenced by parse_url(), and test().

char* hostname
 

Definition at line 251 of file ab.c.

int isproxy = 0
 

Definition at line 270 of file ab.c.

Referenced by main(), and test().

int keepalive = 0
 

Definition at line 249 of file ab.c.

Referenced by main(), output_html_results(), output_results(), read_connection(), and test().

char* path
 

Definition at line 253 of file ab.c.

int percentile = 1
 

Definition at line 246 of file ab.c.

Referenced by main(), and output_results().