getrusage: Call to C routine getrusage

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

This is an interface to the C routine getrusage(). It fills in the fields in a C-level struct rusage. The C-level structure can be be supplied by the caller or, alternatively, the default value of the x__usage parameter provides a new instance of that object. The C object can be used as is and the fields accessed from R, or alternatively it can be copied to a rusage-class object in R.

Usage

1
getrusage(x__who, x__usage = new_rusage(), .copy = c(x__usage = FALSE))

Arguments

x__who

either RUSAGE_SELF or RUSAGE_CHILDREN indicating whether to get information about this process or the sub-processes spawned, typically by a call to system. One can only specify one of these, but one can call the function two times with different values for this argument to get the measurements for both this and child processes.

x__usage

an object of class rusagePtr One can pass in a previously allocated value, either explicitly via new_rusage(), or implicitly by reusing an object returned from a previous call to this function, getrusage.

.copy

a logical value indicating whether the rusage structure passed in x__usage should be copied from the C structure to an R object of class rusage or left as a reference to the C structure.

Details

This is programmatically generated code using the RGCCTranslationUnit

Value

A list of length 2. The first element is an integer giving the return value of the C routine getrusage. The second element depends on the value of the .code argument. If this is .code = FALSE, the second element is an R object of class rusagePtr which is a reference to the C-level structure passed as the value for x__usage. If .copy is TRUE, the second element is an object of class rusage-class which is an R-level copy of the C-level structure.

Author(s)

Duncan Temple Lang

References

Man page for getrusage.

See Also

rusage

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 start = getrusage(RUSAGE_SELF)
 invisible(replicate(100, mean(rnorm(1000))))
 end = getrusage(RUSAGE_SELF)

 end$ru_time - start$ru_utime
 end$ru_stime - start$ru_stime

  # Get the result as a regular R-level object,
  # not a reference to a C-level structure.
 ru = getrusage(RUSAGE_SELF, .copy = TRUE)[[2]]

 ru@majflt

omegahat/RTimingTools documentation built on May 24, 2019, 1:55 p.m.