How to calculate elapsed time ?
From: Stuart Clemons (stuart_clemons_at_us.ibm.com)
Date: 01/28/04
- Next message: Trina Espinoza: "function that reads line numbers?"
- Previous message: Joe Echavarria: "Re: Perl code"
- Next in thread: Wiggins D'Anconia: "Re: How to calculate elapsed time ?"
- Reply: Wiggins D'Anconia: "Re: How to calculate elapsed time ?"
- Reply: John W. Krahn: "Re: How to calculate elapsed time ?"
- Reply: James Edward Gray II: "Re: How to calculate elapsed time ?"
- Maybe reply: James Edward Gray II: "Re: How to calculate elapsed time ?"
- Maybe reply: Stuart Clemons: "Re: How to calculate elapsed time ?"
- Reply: Owen Cook: "Re: How to calculate elapsed time ?"
- Reply: Randy W. Sims: "Re: How to calculate elapsed time ?"
- Maybe reply: Toby Stuart: "RE: How to calculate elapsed time ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: beginners@perl.org Date: Tue, 27 Jan 2004 19:50:30 -0500
Hi all:
I'm trying to determine how long an system operation takes. Anyone know
of a simple way to do this ?
I wanted to establish the start time. Then run the operation. Then mark
the finish time. Then substract the start time from the finish time to
get an elapsed time. Here's the simplistic approach I tried. I'm sure I
need a time that is measured in seconds or something like that, but I'm
not sure how to do this.
TIA
Here's what I tried:
#!/usr/bin/perl -w
use warnings;
use strict;
my $start = "Tue Jan 27 15:40:16 2004";
print "This is the start time: $start \n";
system (This is where the system process stuff goes);
my $finish = localtime;
print "This is the finish time: $finish \n";
my $elapsedtime = ("$finish" - "$start") ;
print "This is the time diff: $elapsedtime \n";
The above obviously didn't work. Here's what it returned:
This is the start time: Tue Jan 27 15:40:16 2004
Argument "Tue Jan 27 15:40:16 2004" isn't numeric in subtraction (-) at
C:\Perl\timetest.pl line 13.
This is the finish time: Tue Jan 27 19:45:56 2004
This is the time diff: 0
Argument "Tue Jan 27 19:45:56 2004" isn't numeric in subtraction (-) at
C:\Perl\timetest.pl line ClearCase\Us
- Next message: Trina Espinoza: "function that reads line numbers?"
- Previous message: Joe Echavarria: "Re: Perl code"
- Next in thread: Wiggins D'Anconia: "Re: How to calculate elapsed time ?"
- Reply: Wiggins D'Anconia: "Re: How to calculate elapsed time ?"
- Reply: John W. Krahn: "Re: How to calculate elapsed time ?"
- Reply: James Edward Gray II: "Re: How to calculate elapsed time ?"
- Maybe reply: James Edward Gray II: "Re: How to calculate elapsed time ?"
- Maybe reply: Stuart Clemons: "Re: How to calculate elapsed time ?"
- Reply: Owen Cook: "Re: How to calculate elapsed time ?"
- Reply: Randy W. Sims: "Re: How to calculate elapsed time ?"
- Maybe reply: Toby Stuart: "RE: How to calculate elapsed time ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|