[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Timing of initial string

From: Timothy Murphy
Subject: Timing of initial string
Date: Thu, 30 May 2002 14:07:46 +0100
User-agent: Mutt/1.2.5i

This is probably not a gnokii question,
but a more general Linux or Unix issue.
However, I'd be interested to hear the views
of anyone who has played with the timing 
of the initialising string in gnokii,
consisting of 250 repetitions of character 0x55
with a usleep of 100 microseconds between them.

It says in the code that the timing is "empirical".
I found on my 450MHz Pentium III Linux box
that any usleep up to 10000 microseconds = 0.01s
is equivalent --
in all cases the machine takes 5 seconds
to send the 250 characters.
Further experimentation shows that 
the actual time for the loop is

        n * ( 0.01 + max(0.01,sleep) )

where n is the number of repetitions.

In other words, if you ask the machine to usleep() at all,
it will sleep for at least 0.02 seconds.

Also the range for success is enormously wide.
Just 10 repetitions (I didn't try fewer)
at any interval up to 0.5 seconds
seems to work with my Nokia 6150.

I wonder to what extent this depends on the phone?
and also to what extent my remarks about usleep()
apply to Linux machines in general?

My timing code, for what it is worth
(maybe there is some error in it) is

struct timeval t0,t1,t2;
        // for (count = 0; count < glink->InitLength; count++) {
        for (count = 0; count < 10; count++) {
                // usleep(100);
                device_write(&init_char, 1);
fprintf(stderr,"Time elapsed: %ld.%ld secs\n", t2.tv_sec, t2.tv_usec);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]