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\
68 Not all fields are available on all systems. If it is not possible to get\n\
69 CPU time statistics, the CPU time slots are set to zero. Other missing data\n\
70 are replaced by NaN@. The list of possible fields is:\n\
74 Unshared data size.\n\
77 Number of block input operations.\n\
80 Unshared stack size.\n\
83 Shared memory size.\n\
86 Number of major page faults.\n\
92 Number of minor page faults.\n\
95 Number of messages received.\n\
98 Number of messages sent.\n\
101 Number of involuntary context switches.\n\
104 Number of signals received.\n\
110 Number of voluntary context switches.\n\
113 Number of block output operations.\n\
116 A structure containing the system CPU time used. The structure has the\n\
117 elements @code{sec} (seconds) @code{usec} (microseconds).\n\
120 A structure containing the user CPU time used. The structure has the\n\
121 elements @code{sec} (seconds) @code{usec} (microseconds).\n\
129 #if defined (HAVE_GETRUSAGE)
135 tv_tmp.
assign (
"sec", static_cast<double> (ru.ru_utime.tv_sec));
136 tv_tmp.
assign (
"usec", static_cast<double> (ru.ru_utime.tv_usec));
139 tv_tmp.
assign (
"sec", static_cast<double> (ru.ru_stime.tv_sec));
140 tv_tmp.
assign (
"usec", static_cast<double> (ru.ru_stime.tv_usec));
143 #if ! defined (RUSAGE_TIMES_ONLY)
144 m.
assign (
"maxrss", static_cast<double> (ru.ru_maxrss));
145 m.
assign (
"ixrss", static_cast<double> (ru.ru_ixrss));
146 m.
assign (
"idrss", static_cast<double> (ru.ru_idrss));
147 m.
assign (
"isrss", static_cast<double> (ru.ru_isrss));
148 m.
assign (
"minflt", static_cast<double> (ru.ru_minflt));
149 m.
assign (
"majflt", static_cast<double> (ru.ru_majflt));
150 m.
assign (
"nswap", static_cast<double> (ru.ru_nswap));
151 m.
assign (
"inblock", static_cast<double> (ru.ru_inblock));
152 m.
assign (
"oublock", static_cast<double> (ru.ru_oublock));
153 m.
assign (
"msgsnd", static_cast<double> (ru.ru_msgsnd));
154 m.
assign (
"msgrcv", static_cast<double> (ru.ru_msgrcv));
155 m.
assign (
"nsignals", static_cast<double> (ru.ru_nsignals));
156 m.
assign (
"nvcsw", static_cast<double> (ru.ru_nvcsw));
157 m.
assign (
"nivcsw", static_cast<double> (ru.ru_nivcsw));
167 unsigned long seconds;
168 unsigned long fraction;
170 ticks = t.tms_utime + t.tms_cutime;
171 fraction = ticks %
HZ;
172 seconds = ticks /
HZ;
174 tv_tmp.
assign (
"sec", static_cast<double> (seconds));
175 tv_tmp.
assign (
"usec", static_cast<double> (fraction * 1e6 /
HZ));
178 ticks = t.tms_stime + t.tms_cstime;
179 fraction = ticks %
HZ;
180 seconds = ticks /
HZ;
182 tv_tmp.
assign (
"sec", static_cast<double> (seconds));
183 tv_tmp.
assign (
"usec", static_cast<double> (fraction * 1e6 /
HZ));
195 m.
assign (
"inblock", tmp);
196 m.
assign (
"oublock", tmp);
199 m.
assign (
"nsignals", tmp);
#define DEFUN(name, args_name, nargout_name, doc)
double lo_ieee_nan_value(void)
void assign(const std::string &k, const octave_value &val)
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))