Function: load-average

load-average is a function defined in fns.c.

Signature

(load-average &optional USE-FLOATS)

Documentation

Return list of 1 minute, 5 minute and 15 minute load averages.

Each of the three load averages is multiplied by 100, then converted to integer.

When USE-FLOATS is non-nil, floats will be used instead of integers. These floats are not multiplied by 100.

If the 5-minute or 15-minute load averages are not available, return a shortened list, containing only those averages which are available.

An error is thrown if the load average can't be obtained. In some cases making it work would require Emacs being installed setuid or setgid so that it can read kernel information, and that usually isn't advisable.

Probably introduced at or before Emacs version 15.

Source Code

// Defined in /usr/src/emacs/src/fns.c
{
  double load_ave[3];
  int loads = getloadavg (load_ave, 3);
  Lisp_Object ret = Qnil;

  if (loads < 0)
    error ("load-average not implemented for this operating system");

  while (loads-- > 0)
    {
      Lisp_Object load = (NILP (use_floats)
			  ? double_to_integer (100.0 * load_ave[loads])
			  : make_float (load_ave[loads]));
      ret = Fcons (load, ret);
    }

  return ret;
}