mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-26 07:33:47 +00:00
Add new function current-cpu-time
* doc/lispref/os.texi (Time of Day): Document it. * src/timefns.c (Fcurrent_cpu_time): New function (bug#44674).
This commit is contained in:
parent
92dcd7562c
commit
1110d7326f
@ -1434,6 +1434,13 @@ as @samp{0.1} but is slightly greater than 1/10.
|
||||
@code{time-to-seconds} is an alias for this function.
|
||||
@end defun
|
||||
|
||||
@defun current-cpu-time
|
||||
Return the current @acronym{CPU} time along with its resolution. The
|
||||
return value is a pair @code{(CPU-TICKS . TICKS-PER-SEC)}. The
|
||||
@var{CPU-TICKS} counter can wrap around, so values cannot be
|
||||
meaningfully compared if too much time has passed between them.
|
||||
@end defun
|
||||
|
||||
@node Time Zone Rules
|
||||
@section Time Zone Rules
|
||||
@cindex time zone rules
|
||||
|
5
etc/NEWS
5
etc/NEWS
@ -1513,6 +1513,11 @@ functions.
|
||||
|
||||
* Lisp Changes in Emacs 29.1
|
||||
|
||||
---
|
||||
** New function 'current-cpu-time'.
|
||||
It gives access to the CPU time used by the Emacs process, for
|
||||
example for benchmarking purposes.
|
||||
|
||||
---
|
||||
** New function 'string-edit'.
|
||||
This is meant to be used when the user has to edit a (potentially)
|
||||
|
@ -1775,6 +1775,18 @@ if you need this older timestamp form. */)
|
||||
return make_lisp_time (current_timespec ());
|
||||
}
|
||||
|
||||
#ifdef CLOCKS_PER_SEC
|
||||
DEFUN ("current-cpu-time", Fcurrent_cpu_time, Scurrent_cpu_time, 0, 0, 0,
|
||||
doc: /* Return the current CPU time along with its resolution.
|
||||
The return value is a pair (CPU-TICKS . TICKS-PER-SEC).
|
||||
The CPU-TICKS counter can wrap around, so values cannot be meaningfully
|
||||
compared if too much time has passed between them. */)
|
||||
(void)
|
||||
{
|
||||
return Fcons (make_int (clock ()), make_int (CLOCKS_PER_SEC));
|
||||
}
|
||||
#endif
|
||||
|
||||
DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string,
|
||||
0, 2, 0,
|
||||
doc: /* Return the current local time, as a human-readable string.
|
||||
@ -2014,6 +2026,9 @@ syms_of_timefns (void)
|
||||
DEFSYM (Qencode_time, "encode-time");
|
||||
|
||||
defsubr (&Scurrent_time);
|
||||
#ifdef CLOCKS_PER_SEC
|
||||
defsubr (&Scurrent_cpu_time);
|
||||
#endif
|
||||
defsubr (&Stime_convert);
|
||||
defsubr (&Stime_add);
|
||||
defsubr (&Stime_subtract);
|
||||
|
Loading…
Reference in New Issue
Block a user