Skip to content

Commit 8fd548f

Browse files
committed
Add pipeline usage debug statistics for serf_get.
* test/serf_get.c (main): Track how many requests are pending (were sent but did not yet receive a response) there are for each active connection. git-svn-id: https://svn.apache.org/repos/asf/serf/trunk@1930990 13f79535-47bb-0310-9956-ffa450edef68
1 parent f6dd580 commit 8fd548f

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

test/serf_get.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,9 @@ int main(int argc, const char **argv)
590590
apr_getopt_t *opt;
591591
int opt_c;
592592
const char *opt_arg;
593+
unsigned int prev_min_pending = 0;
594+
unsigned int prev_max_pending = UINT_MAX;
595+
unsigned int prev_all_pending = 0;
593596

594597
apr_initialize();
595598
atexit(apr_terminate);
@@ -834,7 +837,7 @@ int main(int argc, const char **argv)
834837
/* ### Connection or Context should have an allocator? */
835838
app_ctx.bkt_alloc = bkt_alloc;
836839

837-
connections = apr_pcalloc(pool, conn_count * sizeof(serf_connection_t*));
840+
connections = apr_pcalloc(pool, conn_count * sizeof(*connections));
838841
for (i = 0; i < conn_count; i++)
839842
{
840843
conn_baton_t *conn_ctx = apr_pcalloc(pool, sizeof(*conn_ctx));
@@ -910,6 +913,30 @@ int main(int argc, const char **argv)
910913
break;
911914
}
912915
/* Debugging purposes only! */
916+
if (debug) {
917+
unsigned int min_pending = UINT_MAX;
918+
unsigned int max_pending = 0;
919+
unsigned int all_pending = 0;
920+
for (i = 0; i < conn_count; i++) {
921+
serf_connection_t *conn = connections[i];
922+
unsigned int pending = (serf_connection_pending_requests(conn)
923+
- serf_connection_queued_requests(conn));
924+
all_pending += pending;
925+
if (min_pending > pending) min_pending = pending;
926+
if (max_pending < pending) max_pending = pending;
927+
}
928+
if (prev_min_pending != min_pending
929+
|| prev_max_pending != max_pending
930+
|| prev_all_pending != all_pending)
931+
{
932+
fprintf(stderr, ">pending: %u [avg=%0.1f min=%u max=%u]\n",
933+
all_pending, (double)all_pending/conn_count,
934+
min_pending, max_pending);
935+
prev_min_pending = min_pending;
936+
prev_max_pending = max_pending;
937+
prev_all_pending = all_pending;
938+
}
939+
}
913940
serf_debug__closed_conn(app_ctx.bkt_alloc);
914941
}
915942

0 commit comments

Comments
 (0)