Subject: bug#44674: 28.0.50; Adding current-cpu-time for performance tests

From: Stefan Monnier <[email-masked]>
Date: Mon, 16 Nov 2020 15:10:10 -0500

>> > > AFAIU, using 'clock' here is not the best idea, as there are caveats wrt to
>> > > calling 'system', and the origin of the returned value is not well defined
>> > > to be portable.
>> >
>> > What do you mean by "origin" and by "calling 'system'"?
>>
>> Quoting https://pubs.opengroup.org/onlinepubs/9699919799/:
>>
>>           The clock() function shall return the implementation's best
>>           approximation to the processor time used by the process
>>           since the beginning of an implementation-defined era
>>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>           related only to the process invocation.
>>
>> How do you write portable Lisp code that returns consistent results
>> based on such shaky foundations?
>
> For non-walltime clocks, only the difference between two measurements
> is meaningful.

Mabe the API we should expose should give access to the actual time but
only to time-differences, as in:

    (funcall-with-cpu-time FUNCTION)

    Call FUNCTION and return the CPU time used.
    The return value is of the form (TIME . VALUE) where TIME is the CPU
    time used during execution of FUNCTION, measured in seconds, and
    VALUE is the return value of FUNCTION.

-- Stefan