times()
public
Returns a Tms structure (see Process::Tms) that contains user and system
CPU times for this process, and
also for children processes.
t = Process.times
[ t.utime, t.stime, t.cutime, t.cstime ]
Show source
VALUE
rb_proc_times(VALUE obj)
{
const double hertz = get_clk_tck();
struct tms buf;
VALUE utime, stime, cutime, cstime, ret;
times(&buf);
utime = DBL2NUM(buf.tms_utime / hertz);
stime = DBL2NUM(buf.tms_stime / hertz);
cutime = DBL2NUM(buf.tms_cutime / hertz);
cstime = DBL2NUM(buf.tms_cstime / hertz);
ret = rb_struct_new(rb_cProcessTms, utime, stime, cutime, cstime);
RB_GC_GUARD(utime);
RB_GC_GUARD(stime);
RB_GC_GUARD(cutime);
RB_GC_GUARD(cstime);
return ret;
}