Kangry.com [insert cool graphic here]
home | Topics | Logout | Search | Contact | ?? Kangry ?? | Bandwitdh
Topics:
DVR
nvrec
Mplayer
Links
Misc
Commands
Humor

Name

Password

New user

uploaded files
(linux_command_line)-> Mico time measurement with perl submited by Russell Sun 20 Feb 05
Edited Thu 12 Jan 06
Web kangry.com
Now if you only need to the seccond accuracy you can use this:
$start=time;
##  do something you want to measure.
$end=time;
$elapsed=$end-$start;
print "$elapsed seconds elapsed\n";
But, if you need better accuracy, you can use this:

My friend found this, it lets me mesure an event in fractions of a second:
    require 'sys/syscall.ph';
    $TIMEVAL_T = "LL";
    $done = $start = pack($TIMEVAL_T, ());
 
    syscall( &SYS_gettimeofday, $start, 0) != -1  or die "gettimeofday: $!";
### do something here you want to measure
    syscall( &SYS_gettimeofday, $done, 0) != -1
           or die "gettimeofday: $!";
 
    @start = unpack($TIMEVAL_T, $start);
    @done  = unpack($TIMEVAL_T, $done);
 
    # fix microseconds
    for ($done[1], $start[1]) { $_ /= 1_000_000 }
 
    $delta_time = sprintf "%.4f", ($done[0]  + $done[1]  )
                                            -
                                 ($start[0] + $start[1] );

I don't know how accurate it is. I was just looking for fractions of a second 0.1 .. 0.9 .. but it returns 4 digiits , but that comes from the sprintf command, I don't know if that means it's only that accurate. (it might not even be that good )

Now this didn't work the first time for me (rhat 9.0) . perl died with a missing module,not syscal but rather asm:unistd.ph , my friend had found this file on his newer configuration, and on a lark I put his copy in what I figured should be the correct location /usr/lib/perl5/5.8.0/i386-linux-thread-multi/asm (I had to create 'asm') and to my suprise, it worked.

I have saved that copy of unistd.ph here


Add comment or question...:
Subject:
Submited by: NOT email address. Leave blank for anonymous    (Spam Policy)

Enter Text: (text must match image for posting)




This file (the script that presented the data, not the data itself) , last modified Tuesday 12th of November 2024 04:38:55 PM
your client: CCBot/2.0 (https://commoncrawl.org/faq/)
current time: Tuesday 12th of November 2024 04:38:55 PM