times()
public
Returns a Tms structure (see Struct::Tms on page 388)
that contains user and system CPU times for this process.
t = Process.times
[ t.utime, t.stime ]
Show source
/*
* call-seq:
* Process.times => aStructTms
*
* Returns a <code>Tms</code> structure (see <code>Struct::Tms</code>
* on page 388) that contains user and system CPU times for this
* process.
*
* t = Process.times
* [ t.utime, t.stime ] #=> [0.0, 0.02]
*/
VALUE
rb_proc_times(obj)
VALUE obj;
{
const double hertz =
(double)sysconf(_SC_CLK_TCK);
HZ;
struct tms buf;
volatile VALUE utime, stime, cutime, sctime;
times(&buf);
return rb_struct_new(S_Tms,
utime = rb_float_new(buf.tms_utime / hertz),
stime = rb_float_new(buf.tms_stime / hertz),
cutime = rb_float_new(buf.tms_cutime / hertz),
sctime = rb_float_new(buf.tms_cstime / hertz));
rb_notimplement();
}