List:Internals« Previous MessageNext Message »
From:Wojciech Meler Date:June 30 2006 7:04am
Subject:Re: High precision time
View as plain text  
Why not to use UDF ?

#include <mysql/mysql.h>
#include <sys/time.h>

my_bool hrtime_init(UDF_INIT *initid,UDF_ARGS *args, char *message) {
         return 0;
}

void hrtime_deinit(UDF_INIT *initid) {}

double hrtime(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned 
long  *le
ngth, char *is_null, char *error) {
         struct timeval tv;
         gettimeofday(&tv,NULL);

         return ((double)tv.tv_usec)/1000000+tv.tv_sec;
}


oompile it:

gcc -shared -o hrtime.so hrtime.c

and install:

CREATE FUNCTION hrtime RETURNS REAL SONAME 'hrtime.so'


bwillits@stripped wrote:
> Sorry:
> 
> Language:  MySQL native function  (for use in a stored proc)
> OS:  Linux (CentOS)
> 
> thanks,
> BW
> 
> ---- Rick James <rjames@stripped> wrote: 
> 
>>Language?  OS?
>>
>>Perl has HiRes::Timer
>>PHP has microtimes
>>Windows has QueryPerformanceTimer 
>>Java has something
>>
>>
>>>If the answer is no, can you point me to the code for now() 
>>>or similar so I could investigate adding such a function?
>>
> 
> 

Thread
High precision timebwillits29 Jun
  • RE: High precision timeRick James29 Jun
  • Re: High precision timeSergei Golubchik30 Jun
RE: High precision timebwillits29 Jun
  • Re: High precision timeWojciech Meler30 Jun
Re: High precision timebwillits30 Jun
Re: High precision timebwillits1 Jul