13

It's easy to get Epoch-Seconds (timestamp) in perl:

time

But what's with milliseconds? The most effective way seems to be time*1000, but that's not as accurate as I want it to be. Any good hints except for the long terms documented @perldoc?

zengr
  • 38,346
  • 37
  • 130
  • 192
xsigndll
  • 513
  • 1
  • 5
  • 13

3 Answers3

14

The Time::HiRes module has a drop-in replacement for time

$ perl -E 'say time'
1298827929
$ perl -MTime::HiRes=time -E 'say time'
1298827932.67446

You can read more in the perl FAQ

perldoc -q "How can I measure time under a second"
oylenshpeegul
  • 3,404
  • 1
  • 18
  • 18
5

A real world example would be:

use Time::HiRes qw(gettimeofday);
print gettimeofday;
Hawk
  • 551
  • 8
  • 10
0
perl -MTime::HiRes=time -e 'print time;'

For Perl: v5.8.4 built for SunOS (sun4-solaris-64int), oylenshpeegul's answer needs to be modified.

Community
  • 1
  • 1
pds
  • 2,242
  • 1
  • 22
  • 20