Mercurial > libjeffpc
changeset 288:4717f4ebd23d
scgisvc: keep track of timing statistics
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Wed, 26 Jul 2017 10:53:56 +0300 |
parents | 09d5cc5c7f94 |
children | 9a980c50a132 |
files | include/jeffpc/scgisvc.h scgisvc.c |
diffstat | 2 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/include/jeffpc/scgisvc.h Wed Jul 26 10:52:25 2017 +0300 +++ b/include/jeffpc/scgisvc.h Wed Jul 26 10:53:56 2017 +0300 @@ -25,6 +25,7 @@ #include <jeffpc/int.h> #include <jeffpc/nvl.h> +#include <jeffpc/socksvc.h> struct scgi { uint32_t id; @@ -49,6 +50,16 @@ size_t bodylen; void *body; } response; + + /* timing information */ + struct socksvc_stats conn_stats; + struct { + uint64_t read_header_time; /* headers read */ + uint64_t read_body_time; /* body read/callback started */ + uint64_t compute_time; /* callback finished */ + uint64_t write_header_time; /* headers written */ + uint64_t write_body_time; /* body written */ + } scgi_stats; }; extern int scgisvc(const char *host, uint16_t port, int nthreads,
--- a/scgisvc.c Wed Jul 26 10:52:25 2017 +0300 +++ b/scgisvc.c Wed Jul 26 10:53:56 2017 +0300 @@ -24,6 +24,7 @@ #include <jeffpc/atomic.h> #include <jeffpc/io.h> #include <jeffpc/mem.h> +#include <jeffpc/time.h> #include <jeffpc/scgisvc.h> #include <jeffpc/socksvc.h> @@ -273,6 +274,8 @@ if (!req) return ERR_PTR(-ENOMEM); + memset(req, 0, sizeof(struct scgi)); + req->id = atomic_inc(&scgi_request_ids); req->fd = fd; @@ -314,22 +317,34 @@ goto out; } + req->conn_stats = *sockstats; + ret = scgi_read_headers(req); if (ret) goto out_free; + req->scgi_stats.read_header_time = gettime(); + ret = scgi_read_body(req); if (ret) goto out_free; + req->scgi_stats.read_body_time = gettime(); + func(req, NULL); + req->scgi_stats.compute_time = gettime(); + ret = scgi_write_headers(req); if (ret) goto out_free; + req->scgi_stats.write_header_time = gettime(); + ret = scgi_write_body(req); + req->scgi_stats.write_body_time = gettime(); + out_free: scgi_free(req);