Hi,

Holger wrote:

> The resolution of the time! datatype is one nanosecond. To get
> the current date/time with the highest possible resolution provided
> by the operating system use now/precise (with current experimentals
> only). If you only need the time, without the date, use now/precise/time.
>
> The exact resolution depends on the platform, but is one microsecond
> in most cases.
>
> --
> Holger Kruse
> [EMAIL PROTECTED]
>
> --

I am including my Time-tick function, which I used to find out, that the
resolution of my computer timer is 55 milliseconds (a notebook with MS
Windows 95). Warning! Works only with Rebol/Core 2.4.39.3.1 or newer.

Regards
    Ladislav

seconds: func [
    {Compute difference between dates in seconds}
    a [date!] "first date"
    b [date!] "second date"
] [
    b - a * 86400 + (to decimal! b/time) - (to decimal! a/time) +
        (b/zone/hour - a/zone/hour) * 3600
]

time-tick: function [
    {
        Time the clock tick for a computer.
        Works reliably,
        if the execution time
        of the innermost loop block
        is shorter than the clock tick time,
        otherwise it gives the innermost loop block
        execution time instead.
    }
    accuracy [decimal!]
] [
    guess count start time result prev cur ticks
] [
    guess: 0
    count: 1
    while [
        ticks: 0
        start: prev: now/precise
        loop :count [
            if :prev <> cur: now/precise [
                ticks: :ticks + 1
                prev: :cur
            ]
        ]
        time: seconds start cur
        result: 0
        any [
            ticks <= 0
            (
                result: time / ticks
                (abs result - guess) / result + (3 / ticks) > accuracy
            )
        ]
    ][
        guess: result
        count: count * 2
    ]
    result
]


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to