28 #include <sys/times.h>
29 #include <sys/types.h>
31 #ifdef HAVE_SYS_RESOURCE_H
32 #include <sys/resource.h>
35 #if defined (HAVE_SYS_PARAM_H)
36 #include <sys/param.h>
64 @deftypefn {Built-in Function} {} getrusage ()\n\
65 Return a structure containing a number of statistics about the current\n\
66 Octave process. Not all fields are available on all systems. If it is\n\
67 not possible to get CPU time statistics, the CPU time slots are set to\n\
68 zero. Other missing data are replaced by NaN@. The list of possible\n\
73 Unshared data size.\n\
76 Number of block input operations.\n\
79 Unshared stack size.\n\
82 Shared memory size.\n\
85 Number of major page faults.\n\
91 Number of minor page faults.\n\
94 Number of messages received.\n\
97 Number of messages sent.\n\
100 Number of involuntary context switches.\n\
103 Number of signals received.\n\
109 Number of voluntary context switches.\n\
112 Number of block output operations.\n\
115 A structure containing the system CPU time used. The structure has the\n\
116 elements @code{sec} (seconds) @code{usec} (microseconds).\n\
119 A structure containing the user CPU time used. The structure has the\n\
120 elements @code{sec} (seconds) @code{usec} (microseconds).\n\
128 #if defined (HAVE_GETRUSAGE)
134 tv_tmp.
assign (
"sec", static_cast<double> (ru.ru_utime.tv_sec));
135 tv_tmp.
assign (
"usec", static_cast<double> (ru.ru_utime.tv_usec));
138 tv_tmp.
assign (
"sec", static_cast<double> (ru.ru_stime.tv_sec));
139 tv_tmp.
assign (
"usec", static_cast<double> (ru.ru_stime.tv_usec));
142 #if ! defined (RUSAGE_TIMES_ONLY)
143 m.
assign (
"maxrss", static_cast<double> (ru.ru_maxrss));
144 m.
assign (
"ixrss", static_cast<double> (ru.ru_ixrss));
145 m.
assign (
"idrss", static_cast<double> (ru.ru_idrss));
146 m.
assign (
"isrss", static_cast<double> (ru.ru_isrss));
147 m.
assign (
"minflt", static_cast<double> (ru.ru_minflt));
148 m.
assign (
"majflt", static_cast<double> (ru.ru_majflt));
149 m.
assign (
"nswap", static_cast<double> (ru.ru_nswap));
150 m.
assign (
"inblock", static_cast<double> (ru.ru_inblock));
151 m.
assign (
"oublock", static_cast<double> (ru.ru_oublock));
152 m.
assign (
"msgsnd", static_cast<double> (ru.ru_msgsnd));
153 m.
assign (
"msgrcv", static_cast<double> (ru.ru_msgrcv));
154 m.
assign (
"nsignals", static_cast<double> (ru.ru_nsignals));
155 m.
assign (
"nvcsw", static_cast<double> (ru.ru_nvcsw));
156 m.
assign (
"nivcsw", static_cast<double> (ru.ru_nivcsw));
166 unsigned long seconds;
167 unsigned long fraction;
169 ticks = t.tms_utime + t.tms_cutime;
170 fraction = ticks %
HZ;
171 seconds = ticks /
HZ;
173 tv_tmp.
assign (
"sec", static_cast<double> (seconds));
174 tv_tmp.
assign (
"usec", static_cast<double> (fraction * 1e6 /
HZ));
177 ticks = t.tms_stime + t.tms_cstime;
178 fraction = ticks %
HZ;
179 seconds = ticks /
HZ;
181 tv_tmp.
assign (
"sec", static_cast<double> (seconds));
182 tv_tmp.
assign (
"usec", static_cast<double> (fraction * 1e6 /
HZ));
194 m.
assign (
"inblock", tmp);
195 m.
assign (
"oublock", tmp);
198 m.
assign (
"nsignals", tmp);