httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pt...@pobox.com
Subject [PATCH] flood: Add handler relative_times_sizes_process_stats
Date Fri, 07 Feb 2003 16:22:58 GMT
This patch adds an alternative to the handler:
  relative_times_process_stats
The new handler:
  relative_times_sizes_process_stats
includes the number of bytes sent in the request and received in the
response.  This patch retrieves the number of bytes sent and received
from data member "rbufsize" in the request (request_t) and response
(response_t) structures.

The new handler allows you to calculate the bytes sent and received
along with the time spent sending and receiving the data.  The new
columns precede the response status:
  start, connect, write, read, close, sent received status, thread/process ID, url
Here's a sample (the "112" and "1460" are new):
  1044589747892106 40058 40058 40058 40058 112 1460 OK  108 http://localhost/

My apologies for the odd handler name.  I couldn't think of shorter,
yet descriptive, name.

Index: flood_profile.c
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_profile.c,v
retrieving revision 1.23
diff -u -r1.23 flood_profile.c
--- flood_profile.c	7 Feb 2003 07:39:21 -0000	1.23
+++ flood_profile.c	7 Feb 2003 16:02:21 -0000
@@ -287,6 +287,7 @@
     /* Relative Times Report */
     {"report_init",      "relative_times_report_init",   &relative_times_report_init},
     {"process_stats",    "relative_times_process_stats", &relative_times_process_stats},
+    {"process_stats",    "relative_times_sizes_process_stats", &relative_times_sizes_process_stats},
     {"report_stats",     "relative_times_report_stats",  &relative_times_report_stats},
     {"destroy_report",   "relative_times_destroy_report",&relative_times_destroy_report},
 
@@ -305,7 +306,7 @@
 const char * socket_generic_group[] = { "generic_socket_init", "generic_begin_conn", "generic_send_req",
"generic_recv_resp", "generic_end_conn", "generic_socket_destroy", NULL };
 const char * socket_keepalive_group[] = { "keepalive_socket_init", "keepalive_begin_conn",
"keepalive_send_req", "keepalive_recv_resp", "keepalive_end_conn", "keepalive_socket_destroy",
NULL };
 const char * profile_round_robin_group[] = { "round_robin_profile_init", "round_robin_get_next_url",
"round_robin_create_req", "round_robin_postprocess", "round_robin_loop_condition", "round_robin_profile_destroy",
NULL };
-const char * report_relative_times_group[] = { "relative_times_report_init", "relative_times_process_stats",
"relative_times_report_stats", "relative_times_destroy_report", NULL };
+const char * report_relative_times_group[] = { "relative_times_report_init", "relative_times_process_stats",
"relative_times_sizes_process_stats", "relative_times_report_stats", "relative_times_destroy_report",
NULL };
 
 profile_group_handler_t profile_group_handlers[] = {
     {"report", "easy", report_easy_group },
Index: flood_report_relative_times.c
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_report_relative_times.c,v
retrieving revision 1.6
diff -u -r1.6 flood_report_relative_times.c
--- flood_report_relative_times.c	3 Feb 2003 17:10:56 -0000	1.6
+++ flood_report_relative_times.c	7 Feb 2003 16:02:22 -0000
@@ -76,31 +76,22 @@
     return APR_SUCCESS;
 }
 
-apr_status_t relative_times_process_stats(report_t *report, int verified, request_t *req,
response_t *resp, flood_timer_t *timer)
+static apr_status_t process_stats_tail(char *buf,
+                                       apr_size_t buflen,
+                                       const apr_size_t maxlen,
+                                       int verified,
+                                       const request_t *req)
 {
-#define FLOOD_PRINT_BUF 256
-    apr_size_t buflen;
-    char buf[FLOOD_PRINT_BUF];
-
-    buflen = apr_snprintf(buf, FLOOD_PRINT_BUF,
-                          "%" APR_INT64_T_FMT " %" APR_INT64_T_FMT
-                          " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT,
-                          timer->begin,
-                          timer->connect - timer->begin,
-                          timer->write - timer->begin,
-                          timer->read - timer->begin,
-                          timer->close - timer->begin);
-
     switch (verified)
     {
     case FLOOD_VALID:
-        apr_snprintf(buf+buflen, FLOOD_PRINT_BUF-buflen, " OK ");
+        apr_snprintf(buf + buflen, maxlen - buflen, " OK ");
         break;
     case FLOOD_INVALID:
-        apr_snprintf(buf+buflen, FLOOD_PRINT_BUF-buflen, " FAIL ");
+        apr_snprintf(buf + buflen, maxlen - buflen, " FAIL ");
         break;
     default:
-        apr_snprintf(buf+buflen, FLOOD_PRINT_BUF-buflen, " %d ", verified);
+        apr_snprintf(buf + buflen, maxlen - buflen, " %d ", verified);
     }
 
     /* FIXME: this call may need to be in a critical section */
@@ -111,6 +102,54 @@
 #endif
 
     return APR_SUCCESS;
+}
+
+/* The buffer size was changed from 256 to 384 to help accommodate
+   large URLs and several 64-bit integers. */
+#define FLOOD_PRINT_BUF 384
+
+apr_status_t relative_times_process_stats(report_t *report,
+                                          int verified,
+                                          request_t *req,
+                                          response_t *resp,
+                                          flood_timer_t *timer)
+{
+    apr_size_t buflen;
+    char buf[FLOOD_PRINT_BUF];
+
+    buflen = apr_snprintf(buf, sizeof(buf),
+                          "%" APR_INT64_T_FMT " %" APR_INT64_T_FMT
+                          " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT,
+                          timer->begin,
+                          timer->connect - timer->begin,
+                          timer->write - timer->begin,
+                          timer->read - timer->begin,
+                          timer->close - timer->begin);
+
+    return process_stats_tail(buf, buflen, sizeof(buf), verified, req);
+}
+
+apr_status_t relative_times_sizes_process_stats(report_t *report,
+                                                int verified,
+                                                request_t *req,
+                                                response_t *resp,
+                                                flood_timer_t *timer)
+{
+    apr_size_t buflen;
+    char buf[FLOOD_PRINT_BUF];
+
+    buflen = apr_snprintf(buf, sizeof(buf),
+                          "%" APR_INT64_T_FMT " %" APR_INT64_T_FMT
+                          " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT
+                          " %" APR_SIZE_T_FMT " %" APR_SIZE_T_FMT,
+                          timer->begin,
+                          timer->connect - timer->begin,
+                          timer->write - timer->begin,
+                          timer->read - timer->begin,
+                          timer->close - timer->begin,
+                          req->rbufsize, resp->rbufsize);
+
+    return process_stats_tail(buf, buflen, sizeof(buf), verified, req);
 }
 
 apr_status_t relative_times_report_stats(report_t *report)
Index: flood_report_relative_times.h
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_report_relative_times.h,v
retrieving revision 1.2
diff -u -r1.2 flood_report_relative_times.h
--- flood_report_relative_times.h	3 Feb 2003 17:10:56 -0000	1.2
+++ flood_report_relative_times.h	7 Feb 2003 16:02:22 -0000
@@ -66,6 +66,8 @@
 
 apr_status_t relative_times_process_stats(report_t *report, int verified, request_t *req,
response_t *resp, flood_timer_t *timer);
 
+apr_status_t relative_times_sizes_process_stats(report_t *report, int verified, request_t
*req, response_t *resp, flood_timer_t *timer);
+
 apr_status_t relative_times_report_stats(report_t *report);
 
 apr_status_t relative_times_destroy_report(report_t *report);

Mime
View raw message