Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Interpreting the Meaning of Time Method in Proc::ProcessTable

by monkfan (Curate)
on Oct 26, 2007 at 09:53 UTC ( #647351=perlquestion: print w/ replies, xml ) Need Help??
monkfan has asked for the wisdom of the Perl Monks concerning the following question:

I have a following snippet:
use Proc::ProcessTable; my $now = time; print "NOW:", scalar(localtime $now),"\n"; $t = new Proc::ProcessTable; printf( $FORMAT, "START", "HOWLONG", "CMD" ); foreach $p ( @{ $t->table } ) { printf( $FORMAT, scalar( localtime( $p->start ) ), $p->time, ); } }
And it prints:
NOW :Fri Oct 26 17:37:58 2007
and in one of the entry it prints: prints:
START HOWLONG Fri Oct 26 03:23:00 2007 120000
I was wondering what does the figure 12000 mean? The doc doesn't seem to describe it tangibly:
time user + system time
Does that figure describe howlong a particular program is running? Is that in seconds?

Regards,
Edward

Comment on Interpreting the Meaning of Time Method in Proc::ProcessTable
Select or Download Code
Re: Interpreting the Meaning of Time Method in Proc::ProcessTable
by kyle (Abbot) on Oct 26, 2007 at 12:13 UTC

    It's how much CPU time the process has used (in seconds, I assume). 'User' time is how much time was spent in the program itself and 'system' time is how much time was spent in the operating system servicing the program's requests.

    Update: Upon further reflection, I don't think that time is in seconds. Proc::ProcessTable::Process says that utime is in 1/100s of seconds, so that's probably what time is in too. Your 120000 figure is 33 hours as seconds and 20 minutes as 1/100s of seconds. If you're still in doubt, you could see what it says about "perl -e '$i++ while 1'" after ten seconds. My guess is it will be about 1000.

      Sorry, but I still don't get it... ProcessTable says this:
      PID    PPID   SIZE         RSS          TIME         COMMAND
      19524  14920  936000       762796       55550000     /tools/atoptech/AP_07.06-06.27/Linux/bin/rhel3-64/AP 
      
      and ps says this about the same process:
      % ps -o 'ppid pid vsz rss time command'
       PPID   PID   VSZ  RSS     TIME COMMAND
      14920 19524 936000 762796 00:00:55 /tools/atoptech/AP_07.06-06.27/Linux/bin/rhel3-64/AP
      
      Thanks, Jim

        It looks as if ps is reporting time in seconds (hours, minutes, seconds, separated by colons) and Proc::ProcessTable is reporting it in microseconds. If what you have is microseconds, you can convert that to seconds by dividing by one million.

        my $microseconds = 55550000; my $seconds = $microseconds / 1_000_000;
Re: Interpreting the Meaning of Time Method in Proc::ProcessTable
by karlgoethebier (Curate) on Apr 04, 2014 at 09:56 UTC

    kyle is right. From README.linux:

    SUPPORTED ATTRIBUTES ==================== uid UID of process euid Effective UID of process suid Saved UID of process fuid File UID of process gid GID of process egid Effective GID of process sgid Saved GID of process fgid File GID of process pid process ID ppid parent process ID pgrp process group sess session ID priority priority of process ttynum tty number of process flags flags of process minflt minor page faults cminflt child minor page faults majflt major page faults cmajflt child major page faults utime user mode time (microseconds) stime kernel mode time (microseconds) cutime child utime (microseconds) cstime child stime (microseconds) time user + system time (microseconds) ctime child user + system time (microseconds) size virtual memory size (bytes) rss resident set size (bytes) wchan address of current system call fname file name start start time (seconds since the epoch) pctcpu percent cpu used since process started state state of process pctmem percent memory cmndline full command line of process exec absolute filename (including path) of executed command ttydev path of process's tty cwd current directory of process NOTE ==== This now correctly gives you microseconds. Previously all times were +actually in milliseconds even though this file said microseconds. -Jason Smith BUGS ==== Though times are now converted to microseconds, they are limited to ji +ffie resolution. A jiffie is 100 Hertz on most platforms, 1024 Hertz on Al +pha. -Philip Gwyn

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://647351]
Approved by Corion
Front-paged by neversaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-09-18 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (124 votes), past polls