GNU bug report logs - #44674
28.0.50; Adding current-cpu-time for performance tests

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Mon, 16 Nov 2020 01:08:01 UTC

Severity: wishlist

Tags: moreinfo

Found in version 28.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Philipp Stephani <p.stephani2 <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 44674 <at> debbugs.gnu.org
Subject: bug#44674: 28.0.50; Adding current-cpu-time for performance tests
Date: Mon, 16 Nov 2020 08:13:32 +0100
Am Mo., 16. Nov. 2020 um 02:08 Uhr schrieb Stefan Monnier
<monnier <at> iro.umontreal.ca>:

> +#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

Looks useful!

It might be beneficial to use the higher-resolution clock_gettime with
CLOCK_PROCESS_CPUTIME_ID if available and only fall back to clock()
otherwise.

While there, consider also implementing a function to read the
CLOCK_MONOTONIC clock – that should be preferred over the realtime
clock for stopwatch-style measurements.




This bug report was last modified 3 years and 107 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.