Perl equivalent of Unix time command

This is a discussion on Perl equivalent of Unix time command within the Perl forums in Programming Languages category; Hi all, I want to benchmark a bunch of running processes using Perl , but I could not find any equivalent for the unic time coammnd in perl? Can someone point to me if such a function exists in perl? The only command I found was "times", but I don't know how to use it. doing a websearch did not help. Thanks...

Go Back   Application Development Forum > Programming Languages > Perl

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-07-2008, 12:30 PM
Melroy
Guest
 
Default Perl equivalent of Unix time command

Hi all,
I want to benchmark a bunch of running processes using Perl , but I
could not find any equivalent for the unic time coammnd in perl? Can
someone point to me
if such a function exists in perl? The only command I found was
"times",
but I don't know how to use it. doing a websearch did not help.
Thanks

Reply With Quote
  #2  
Old 09-07-2008, 10:09 PM
Jeff Pang
Guest
 
Default Re: Perl equivalent of Unix time command

2008/9/8 Melroy <melroysoares@hotmail.com>:
> Hi all,
> I want to benchmark a bunch of running processes using Perl , but I
> could not find any equivalent for the unic time coammnd in perl? Can
> someone point to me
> if such a function exists in perl?



use Benchmark::Timer;
http://search.cpan.org/~dcoppit/Benc...hmark/Timer.pm
Reply With Quote
  #3  
Old 09-08-2008, 05:44 AM
Raymond Wan
Guest
 
Default Re: Perl equivalent of Unix time command


Hi Melroy,

Others have replied with information about benchmarking; if all you want
is to do what /usr/bin/time does, then yes, "times" is all you need.
Note that it isn't "benchmarking", it is doing exactly what
/usr/bin/time does...give you the process time. Benchmarking is a
stronger work, and that requires the aforementioned library.

As http://perldoc.perl.org/functions/times.html says, all you do is:

($user,$system,$cuser,$csystem) = times;

The result is a 4-element array and depends on whether you want the time
of the current or child process and which time (user or system).

"times" takes a snapshot of the time at that point in the program.
/usr/bin/time does the same thing, but at the end of your program (and
thus, reports the time for the entire program). If you want to test a
portion of code, call "times" at the beginning and again at the end of
that section of code. Then, take the difference and convert the result
from seconds to whatever you want.

Ray



Melroy wrote:
> Hi all,
> I want to benchmark a bunch of running processes using Perl , but I
> could not find any equivalent for the unic time coammnd in perl? Can
> someone point to me
> if such a function exists in perl? The only command I found was
> "times",
> but I don't know how to use it. doing a websearch did not help.
> Thanks
>
>
>


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:07 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.