Time-HR-0.02/004275500021150000026000000000000745531175300145665ustar00agolomshtokespdev00003540000004Time-HR-0.02/README010064400021150000026000000016250742761102200154340ustar00agolomshtokespdev00003540000004Time/HR version 0.01 ==================== Time::HR is a very simple interface to high-resolution timer - it only supports one function call - gethrtime(). gethrtime() function returns current high-resolution real time value either as 64-bit integer (on systems with 64-bit support) or double value. Time is expressed as nanoseconds since some arbitrary time in the past; it is not correlated in any way to the time of day, and thus is not subject to resetting or drifting by way of adjtime or settimeofday. The high resolution timer is ideally suited to performance measurement tasks, where cheap, accurate interval timing is required. Currently, this extension is only supported on Solaris, Linux and Cygwin. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES None COPYRIGHT AND LICENCE Copyright (C) 2002 Alexander Golomshtok Time-HR-0.02/MANIFEST010064400021150000026000000001000742760067200157010ustar00agolomshtokespdev00003540000004Changes HR.pm HR.xs Makefile.PL MANIFEST README test.pl typemap Time-HR-0.02/HR.pm010064400021150000026000000051700745530712200154260ustar00agolomshtokespdev00003540000004package Time::HR; use 5.006; use strict; use warnings; use Carp; require Exporter; require DynaLoader; use AutoLoader; our @ISA = qw(Exporter DynaLoader); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. # This allows declaration use Time::HR ':all'; # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. our %EXPORT_TAGS = ( 'all' => [ qw( gethrtime ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( gethrtime ); our $VERSION = '0.02'; sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() # XS function. If a constant is not found then control is passed # to the AUTOLOAD in AutoLoader. my $constname; our $AUTOLOAD; ($constname = $AUTOLOAD) =~ s/.*:://; croak "& not defined" if $constname eq 'constant'; my $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { if ($! =~ /Invalid/ || $!{EINVAL}) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } else { croak "Your vendor has not defined Time::HR macro $constname"; } } { no strict 'refs'; # Fixed between 5.005_53 and 5.005_61 if ($] >= 5.00561) { *$AUTOLOAD = sub () { $val }; } else { *$AUTOLOAD = sub { $val }; } } goto &$AUTOLOAD; } bootstrap Time::HR $VERSION; # Preloaded methods go here. # Autoload methods go after =cut, and are processed by the autosplit program. 1; __END__ # Below is stub documentation for your module. You better edit it! =head1 NAME Time::HR - Perl interface to high-resolution timer. =head1 SYNOPSIS use Time::HR; $hrtime = gethrtime(); =head1 DESCRIPTION Time::HR is a very simple interface to high-resolution timer - it only supports one function call - gethrtime(). gethrtime() function returns current high-resolution real time value either as 64-bit integer (on systems with 64-bit support) or double value. Time is expressed as nanoseconds since some arbitrary time in the past; it is not correlated in any way to the time of day, and thus is not subject to resetting or drifting by way of adjtime or settimeofday. The high resolution timer is ideally suited to performance measurement tasks, where cheap, accurate interval timing is required. Currently, this extension is only supported on Solaris, Linux and Cygwin. =head2 EXPORT gethrtime =head2 Exportable constants none =head1 AUTHOR Alexander Golomshtok, golomshtok_alexander@jpmorgan.com =head1 SEE ALSO L. =cut Time-HR-0.02/test.pl010064400021150000026000000010030742761110600160610ustar00agolomshtokespdev00003540000004# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test; BEGIN { plan tests => 1 }; use Time::HR; ok(1); # If we made it this far, we're ok. ok(1) unless !gethrtime(); ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. Time-HR-0.02/typemap010064400021150000026000000001720742661722300161620ustar00agolomshtokespdev00003540000004func_return_t T_FUNCRET INPUT T_FUNCRET _T_FUNCRET_INPUT($arg,$var) OUTPUT T_FUNCRET _T_FUNCRET_OUTPUT($arg,$var) Time-HR-0.02/Changes010064400021150000026000000007250745530706700160630ustar00agolomshtokespdev00003540000004Revision history for Perl extension Time::HR. 0.02 Sat Apr 6 02:14:41 CEST 2002 by Márton Németh - minor changes: we also need perl 5.006 for install not only for run - author name corrected - using 'gettimeofday(&ts, NULL)' instead of 'clock_gettime(CLOCK_REALTIME, &ts)' on Linux if the second not exists 0.01 Thu Jan 31 13:14:40 2002 - original version; created by h2xs 1.21 with options -nTime::HR -v0.01 /usr/include/sys/time.h Time-HR-0.02/Makefile.PL010064400021150000026000000021040745530740700165310ustar00agolomshtokespdev00003540000004use 5.006; use ExtUtils::MakeMaker; use Config; use Carp; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. croak "unsupported OS [$Config{'osname'}] - see README!!!\n" unless grep($Config{'osname'}, qw(linux solaris cygwin)); WriteMakefile( 'NAME' => 'Time::HR', 'VERSION_FROM' => 'HR.pm', # finds $VERSION 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'HR.pm', # retrieve abstract from module AUTHOR => 'Alexander Golomshtok ') : ()), 'LIBS' => [''], # e.g., '-lm' # Insert -I. if you add *.h files later: 'INC' => '', # e.g., '-I/usr/include/other' # Un-comment this if you add C files to link with later: # 'OBJECT' => '$(O_FILES)', # link all the C files too 'CONFIGURE' => sub {{ 'DEFINE' => '-D_'.uc((grep(/$Config{'osname'}/, qw(solaris linux cygwin)))[0]), 'LIBS' => $Config{'osname'} eq 'linux' ? ['-lrt'] : [] }} ); Time-HR-0.02/HR.xs010064400021150000026000000027510745530732400154520ustar00agolomshtokespdev00003540000004#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #if defined _SOLARIS #include #include #if defined USE_64_BIT_INT typedef uint64_t func_return_t; #else typedef double func_return_t; #endif #endif #if defined _LINUX #include #include #if defined USE_64_BIT_INT typedef u_int64_t func_return_t; #else typedef double func_return_t; #endif #endif #if defined _CYGWIN #include #if defined USE_64_BIT_INT typedef ULARGE_INTEGER func_return_t; #else typedef double func_return_t; #endif #endif #if defined USE_64_BIT_INT # define _T_FUNCRET_INPUT(arg,var) var = (func_return_t)SvUV(arg) # define _T_FUNCRET_OUTPUT(arg,var) sv_setuv(arg, (UV)var); #else # define _T_FUNCRET_INPUT(arg,var) var = (func_return_t)SvNV(arg) # define _T_FUNCRET_OUTPUT(arg,var) sv_setnv(arg, (func_return_t)var); #endif func_return_t _gethrtime() { #if defined _SOLARIS return gethrtime(); #endif #if defined _LINUX #if defined CLOCK_REALTIME struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); return ((func_return_t)ts.tv_sec)*1e9+ts.tv_nsec; #else struct timeval tv; gettimeofday(&tv, NULL); return ((func_return_t)tv.tv_sec)*1e9+tv.tv_usec*1e3; #endif #endif #if defined _CYGWIN LARGE_INTEGER ts; QueryPerformanceCounter(&ts); return (func_return_t)ts.QuadPart; #endif } MODULE = Time::HR PACKAGE = Time::HR func_return_t gethrtime() CODE: RETVAL = _gethrtime(); OUTPUT: RETVAL