| 1 |
\name{Sys.cpuinfo} |
| 2 |
\alias{Sys.procinfo} |
| 3 |
\alias{Sys.cpuinfo} |
| 4 |
\alias{Sys.meminfo} |
| 5 |
\alias{Sys.memGB} |
| 6 |
\alias{Sys.MIPS} |
| 7 |
\title{Provide Information about the Linux Hardware (CPU, Memory, etc)} |
| 8 |
\description{ |
| 9 |
Return information about the Linux hardware, notably |
| 10 |
the CPU (the central processor unit) and memory of the |
| 11 |
computer \R is running on. |
| 12 |
This is currently \bold{only available for Linux}. |
| 13 |
|
| 14 |
These functions exist on other unix-alike platforms, but produce an |
| 15 |
error when called. |
| 16 |
} |
| 17 |
\usage{ |
| 18 |
Sys.procinfo(procfile) |
| 19 |
Sys.cpuinfo() |
| 20 |
Sys.meminfo() |
| 21 |
Sys.memGB(kind = "MemTotal") |
| 22 |
Sys.MIPS() |
| 23 |
} |
| 24 |
\arguments{ |
| 25 |
\item{procfile}{name of file the lines of which give the CPU info ``as |
| 26 |
on Linux''} |
| 27 |
\item{kind}{a \code{\link{character}} string specifying which |
| 28 |
\emph{kind} of memory is desired.} |
| 29 |
} |
| 30 |
\value{ |
| 31 |
The \code{Sys.*info()} functions return a \code{"simple.list"}, |
| 32 |
here basically a named character vector, |
| 33 |
(where the names have been filtered through \code{\link{make.names}(*, |
| 34 |
unique=TRUE)} which is of importance for multi-processor or multi-core |
| 35 |
CPUs, such that vector can easily be indexed. |
| 36 |
|
| 37 |
\code{Sys.memGB()} returns available memory in giga bytes [GB];\cr |
| 38 |
\code{Sys.MIPS()} returns a number giving an approximation of |
| 39 |
the \bold{M}illion \bold{I}instructions \bold{P}er \bold{S}econd that |
| 40 |
the CPU processes (using \dQuote{bogomips}). This is a performance |
| 41 |
measure of the basic \emph{non-numeric} processing capabilities. |
| 42 |
For single-core Linux systems, often about twice the basic clock rate |
| 43 |
in ``MHz'' (as available by \code{Sys.cpuinfo()["cpu.MHz"]}); now, |
| 44 |
with multicore systems, the result is often around (but smaller than) |
| 45 |
\code{2 * #\{cores\} * clock.rate}. |
| 46 |
} |
| 47 |
\author{Martin Maechler} |
| 48 |
\note{These currently do rely on the Linux \file{/proc/} file system, and may not |
| 49 |
easily be portable to non-Linux environments. |
| 50 |
|
| 51 |
On multi-processor machines, \code{Sys.cpuinfo()} contains each field |
| 52 |
for each processor (i.e., \code{names(Sys.cpuinfo())} has |
| 53 |
\code{\link{duplicated}} entries). |
| 54 |
|
| 55 |
Conceivably, the bogoMIPS source code is open and available and could |
| 56 |
be built into \R. |
| 57 |
} |
| 58 |
\seealso{\code{\link{Sys.ps}}, etc.} |
| 59 |
|
| 60 |
\examples{ |
| 61 |
(n.cores <- parallel::detectCores()) |
| 62 |
if(substr(R.version[["os"]], 1,5) == "linux") { ##-- only on Linux |
| 63 |
Sys.cpuinfo() # which is often ugly; this looks much better: |
| 64 |
length(Sys.cpu2 <- local({I <- Sys.cpuinfo(); I[ !grepl("^flags", names(I)) ] })) |
| 65 |
## may still be too much, notably if n.cores > 2: |
| 66 |
(Sys3 <- Sys.cpu2[!grepl("[.][0-9]+$", names(Sys.cpu2))]) |
| 67 |
|
| 68 |
Sys.MIPS() ## just the 'bogomips' from above: |
| 69 |
Sys.MIPS() / as.numeric(Sys.cpuinfo()["cpu.MHz"]) ## ~~ 2 * #{cores} ((no longer)) |
| 70 |
|
| 71 |
## Available Memory -- can be crucial: |
| 72 |
Sys.memGB() #- default "MemTotal" |
| 73 |
if(Sys.memGB("MemFree") > 16) |
| 74 |
message("Be happy! You have more than 16 Gigabytes of free memory") |
| 75 |
} |
| 76 |
} |
| 77 |
\keyword{utilities} |