[Openmcl-devel] CCL 1.9 release candidate available

Wade Humeniuk wade.humeniuk at gmail.com
Wed Feb 6 17:01:11 PST 2013


From a post at http://stackoverflow.com/questions/275004/c-timer-function-to-provide-time-in-nano-seconds (see the full post for how to get nanoseconds)

I assume ccl can generate machine instructions directly...

Wade

<quote>

Here's the actual code to retrieve number of 80x86 CPU clock ticks passed since the CPU was last started. It will work on Pentium and above (386/486 not supported). This code is actually MS Visual C++ specific, but can be probably very easy ported to whatever else, as long as it supports inline assembly.

inline __int64 GetCpuClocks()
{

    // Counter
    struct { int32 low, high; } counter;

    // Use RDTSC instruction to get clocks count
    __asm push EAX
    __asm push EDX
    __asm __emit 0fh __asm __emit 031h // RDTSC
    __asm mov counter.low, EAX
    __asm mov counter.high, EDX
    __asm pop EDX
    __asm pop EAX

    // Return result
    return *(__int64 *)(&counter);

}
This function has also the advantage of being extremely fast - it usually takes no more than 50 cpu cycles to execute.

</quote>

On 2013-02-06, at 3:08 PM, "R. Matthew Emerson" <rme at clozure.com> wrote:

> 
> On Feb 6, 2013, at 4:24 PM, Alexander Repenning <Alexander.Repenning at colorado.edu> wrote:
> 
>> 
>> On Feb 6, 2013, at 1:48 PM, R. Matthew Emerson wrote:
>> 
>>> 
>>> On Feb 6, 2013, at 3:36 PM, Alexander Repenning <alexander.repenning at Colorado.EDU> wrote:
>>> 
>>>> from the release notes:
>>>> 
>>>>> access to high-resolution clock
>>>>> 
>>>>> CCL:CURRENT-TIME-IN-NANOSECONDS returns the number of elapsed nanoseconds since some arbitrary point in time (likely system boot.)
>>>>> 
>>>> 
>>>> This sounds very useful. What is the approximate resolution of this function on Windows, i.e., what kind of Windows timer function is this based on?
>>> 
>>> Pressing M-. on current-time-in-nanoseconds leads me to its definition in ccl:lib;time.lisp.  On Windows, that function uses #_GetSystemTimeAsFileTime.
>> 
>> 
>> I was afraid of that because on most Windows systems, certainly XP, that would suggest a 15ms resolution which is rather disappointing. 
> 
> If you know of a Windows function that that would provide superior results, I'd love to hear about it.
> 
> QueryPerformanceCounter() is not a good solution.  It requires a lot of effort to compensate for its limitations.   See, for example, https://bugzilla.mozilla.org/show_bug.cgi?id=676349
> 
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20130206/d78de076/attachment.htm>


More information about the Openmcl-devel mailing list