Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: Dev

Proposal for CPAN module: Apache2::RequestRec::Time

 

 

ModPerl dev RSS feed   Index | Next | Previous | View Threaded


jpz-mlmp at adelton

Aug 13, 2009, 12:21 PM

Post #1 of 4 (948 views)
Permalink
Proposal for CPAN module: Apache2::RequestRec::Time

Hello,

related to my previous post about getting to microsecond values
from APR/mod_perl, I propose to submit to CPAN a module
Apache2::RequestRec::Time which will add four functions (methods)
to Apache2::RequestRec: request_time_hires, request_duration,
request_duration_microseconds, and request_duration_hires.

My main goal is to be able to get value equivalent to custom
log's %D (time taken to serve the request, in microseconds) from
mod_perl, which request_duration_microseconds will do, and I wanted
the set of methods to be a big more complete in case people wanted
similar yet not exact functionality. Initially, I also planned to
have request_time_microseconds but I hit integer overflows as epoch
in microseconds is fairly big number.

I'd appreciate any comments about suitability of such module and/or
its name, purpose, or implementation (for code, see below) before
I do the CPAN submission. Of course, the CPAN distribution will be
complete with Makefile.PL and test.

Thank you.

For the reference, my planned XS code is:

#include <mod_perl.h>

typedef request_rec *Apache2__RequestRec;

MODULE = Apache2::RequestRec::Time PACKAGE = Apache2::RequestRec PREFIX = mpxs_Apache2__RequestRec_

double
mpxs_Apache2__RequestRec_request_time_hires(r)
Apache2::RequestRec r
CODE:
RETVAL = (double)(r->request_time) / APR_USEC_PER_SEC;
OUTPUT:
RETVAL

long
mpxs_Apache2__RequestRec_request_duration(r)
Apache2::RequestRec r
CODE:
apr_time_t duration = apr_time_now() - r->request_time;
RETVAL = apr_time_sec(duration);
OUTPUT:
RETVAL

double
mpxs_Apache2__RequestRec_request_duration_microseconds(r)
Apache2::RequestRec r
CODE:
RETVAL = (double)(apr_time_now() - r->request_time);
OUTPUT:
RETVAL

double
mpxs_Apache2__RequestRec_request_duration_hires(r)
Apache2::RequestRec r
CODE:
RETVAL = (double)(apr_time_now() - r->request_time) / APR_USEC_PER_SEC;
OUTPUT:
RETVAL

--
Jan Pazdziora

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe[at]perl.apache.org
For additional commands, e-mail: dev-help[at]perl.apache.org


fred at redhotpenguin

Aug 13, 2009, 12:46 PM

Post #2 of 4 (886 views)
Permalink
Re: Proposal for CPAN module: Apache2::RequestRec::Time [In reply to]

On Thu, Aug 13, 2009 at 12:21 PM, Jan Pazdziora<jpz-mlmp[at]adelton.com> wrote:
> related to my previous post about getting to microsecond values
> from APR/mod_perl, I propose to submit to CPAN a module
> Apache2::RequestRec::Time which will add four functions (methods)
> to Apache2::RequestRec: request_time_hires, request_duration,
> request_duration_microseconds, and request_duration_hires.

I can't speak for the whole dev team, but I don't see any reason
offhand why these methods couldn't be included in the core since they
are RequestRec based. This code is based off of the C api so it makes
a bit more sense to me to have it in core than as an external module.

From my limited understanding of the mod_perl XS api this looks like
great start!

>
> My main goal is to be able to get value equivalent to custom
> log's %D (time taken to serve the request, in microseconds) from
> mod_perl, which request_duration_microseconds will do, and I wanted
> the set of methods to be a big more complete in case people wanted
> similar yet not exact functionality. Initially, I also planned to
> have request_time_microseconds but I hit integer overflows as epoch
> in microseconds is fairly big number.
>
> I'd appreciate any comments about suitability of such module and/or
> its name, purpose, or implementation (for code, see below) before
> I do the CPAN submission. Of course, the CPAN distribution will be
> complete with Makefile.PL and test.
>
> Thank you.
>
> For the reference, my planned XS code is:
>
> #include <mod_perl.h>
>
> typedef request_rec *Apache2__RequestRec;
>
> MODULE = Apache2::RequestRec::Time      PACKAGE = Apache2::RequestRec   PREFIX = mpxs_Apache2__RequestRec_
>
> double
> mpxs_Apache2__RequestRec_request_time_hires(r)
>                Apache2::RequestRec r
>        CODE:
>                RETVAL = (double)(r->request_time) / APR_USEC_PER_SEC;
>        OUTPUT:
>                RETVAL
>
> long
> mpxs_Apache2__RequestRec_request_duration(r)
>                Apache2::RequestRec r
>        CODE:
>                apr_time_t duration = apr_time_now() - r->request_time;
>                RETVAL = apr_time_sec(duration);
>        OUTPUT:
>                RETVAL
>
> double
> mpxs_Apache2__RequestRec_request_duration_microseconds(r)
>                Apache2::RequestRec r
>        CODE:
>                RETVAL = (double)(apr_time_now() - r->request_time);
>        OUTPUT:
>                RETVAL
>
> double
> mpxs_Apache2__RequestRec_request_duration_hires(r)
>                Apache2::RequestRec r
>        CODE:
>                RETVAL = (double)(apr_time_now() - r->request_time) / APR_USEC_PER_SEC;
>        OUTPUT:
>                RETVAL
>
> --
> Jan Pazdziora
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe[at]perl.apache.org
> For additional commands, e-mail: dev-help[at]perl.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe[at]perl.apache.org
For additional commands, e-mail: dev-help[at]perl.apache.org


jpz-mlmp at adelton

Aug 14, 2009, 9:19 AM

Post #3 of 4 (884 views)
Permalink
Re: Proposal for CPAN module: Apache2::RequestRec::Time [In reply to]

On Thu, Aug 13, 2009 at 12:46:50PM -0700, Fred Moyer wrote:
> On Thu, Aug 13, 2009 at 12:21 PM, Jan Pazdziora<jpz-mlmp[at]adelton.com> wrote:
> > related to my previous post about getting to microsecond values
> > from APR/mod_perl, I propose to submit to CPAN a module
> > Apache2::RequestRec::Time which will add four functions (methods)
> > to Apache2::RequestRec: request_time_hires, request_duration,
> > request_duration_microseconds, and request_duration_hires.
>
> I can't speak for the whole dev team, but I don't see any reason
> offhand why these methods couldn't be included in the core since they
> are RequestRec based. This code is based off of the C api so it makes
> a bit more sense to me to have it in core than as an external module.

Having it in core mod_perl is definitelly also an option.

That however will not bring the functionality to already-released
mod_perl 2 versions around the world. So my idea was to release this
module on CPAN and if it gets to mod_perl core eventually, even
better.

--
Jan Pazdziora

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe[at]perl.apache.org
For additional commands, e-mail: dev-help[at]perl.apache.org


jpz-mlmp at adelton

Sep 11, 2009, 10:47 AM

Post #4 of 4 (686 views)
Permalink
Re: Proposal for CPAN module: Apache2::RequestRec::Time [In reply to]

On Fri, Aug 14, 2009 at 06:19:29PM +0200, Jan Pazdziora wrote:
>
> Having it in core mod_perl is definitelly also an option.
>
> That however will not bring the functionality to already-released
> mod_perl 2 versions around the world. So my idea was to release this
> module on CPAN and if it gets to mod_perl core eventually, even
> better.

I have uploaded Apache2-RequestRec-Time-1.0.tar.gz to CPAN. It
provides request_duration_microseconds, request_duration, and
request_time_microseconds (I left out the _hires variants in the
end). I've sent announcement to modperl[at]perl.apache.org.

Yours,

--
Jan Pazdziora

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe[at]perl.apache.org
For additional commands, e-mail: dev-help[at]perl.apache.org

ModPerl dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.