Mailing List Archive


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

Re: [tlug] A Rich Experiment Indeed



Hello :)

well, I have been reading more and trying to understand. I am doing my
best, but I honestly ask you to be patient with me :) 

So here is what I have found:

My ftime man page says basicaly the same as Jim's. 
eg.
......
BUGS

   This function is obsolete.  Don't use it.  If the time in seconds
   suf- fices,   time(2)  can  be  used;  gettimeofday(2)  gives
   microseconds; clock_gettime(3) gives nanoseconds but is not yet
   widely available.

   Under libc4 and libc5 the  millitm  field is meaningful.   But early
   glibc2 is buggy and returns 0 there; glibc 2.1.1 is correct again.
......


Now, there are 2 points which I would like to clearly express in a hope
for correct understanding of each other :) (again, please be patient
with me...) 

1. I have chacked this immediately after Jim suggested to do so.  So
from my point of view, ftime() is dead and I should forgot about it :)  

2. In my original program (eg. cas.c) I used printf() in a wrong way
(eg. %d.%d instead of %d.%03ld). Again Jim discovered the point as far
as I can understand. The problem was "decimal shift". 
eg. 

measured time[1]   ->    _my_ prinf() result

1.001              ->    1.1     
1.010              ->    1.10
1.100              ->    1.100

                          ^
                          |------ THE SAME NUMBER ! :)   


If I (only) for this moment forget about other very useful tips and
suggestions made by Jim [2], I see two ways of improvement:

A - replace ftime with gettimeofday()
B - replace my printf format with a better one eg. use %d.%03ld 

In Jim's cas2.c only B was implemented. 
In Josh's noname, both A and B ware implemented. 

see :
http://material.karlov.mff.cuni.cz/people/hajek/timetest/cas2.c
http://material.karlov.mff.cuni.cz/people/hajek/timetest/josh_noname.c

I have compiled both and run for a moment [3] with:
$ ./cas2 | uniq | sed -e 's/^113368//g' > cas2.sed
$ ./josh_noname | uniq | sed -e 's/^113368//g' > josh_noname.sed

resulting in:

$ head josh_noname.sed
1994.681644000   
1994.681668000   
1994.681669000   
1994.681670000   
1994.681671000   
1994.681672000   
1994.681673000   
1994.681674000   
1994.681675000   
1994.681676000   
$ head cas2.sed
1967.897         
1967.898         
1967.899         
1967.913         
1967.914         
1967.915         
1967.916         
1967.917         
1967.918         
1967.919         

all data can be seen here (josh_noname.sed is about 31MB big):
http://material.karlov.mff.cuni.cz/people/hajek/timetest/

Dada ploted with gnuplot :
http://material.karlov.mff.cuni.cz/people/hajek/timetest/cas2.png
http://material.karlov.mff.cuni.cz/people/hajek/timetest/josh_noname.png

Hopla! 

Even though Jim did not use gettimeofday(), his program gives more or
less straight line, while Josh's noname gives a saw. 

It is about time to inspect Josh's programm :)))
Perhaps the problem is in this line:

printf("%d.%03ld \t \n",(int)start.tv_sec,start.tv_usec*1000);

Let me change it to :
printf("%d.%06ld \t \n",(int)start.tv_sec,start.tv_usec/1000);
           ^^^^^                                    ^^^^^^^^^

producing:
$ head josh_noname2.sed
3269.000626      
3269.000627      
3269.000634      
3269.000635      
3269.000636      
3269.000637      
3269.000638      
3269.000639      
3269.000640      
3269.000641      

and graphed:
http://material.karlov.mff.cuni.cz/people/hajek/timetest/josh_noname2.png

Oh no! Wrong again... :)

Aha, ... let's use this line instead:
printf("%d.%06ld \t \n",(int)start.tv_sec,start.tv_usec);
                                                  ^^^^^^
and this time we have samwhat good eresult :) 
see:
http://material.karlov.mff.cuni.cz/people/hajek/timetest/josh_noname3.png

The remaining part: zoom out the data and see, if the there is saw on
the smaler scale. 

I still do not understand some parts of rtc.txt from kernel. doc, and
some other timing issues involved, but I will address them in a separate
email.

Finaly, I have noticed, that gnuplot [4] is able to handle mouse clicks
inside graph and some manipulation based on mouse input. I shall learn
these cool tricks definitely! :) 
If anyone has a good totorial page, it would be wellcome.


----------------
[1] whatever tool was used to obtain this data
[2] e.g. using pipes and sed. 
[3] I counted to 20 on fingers :)) Not really exact "clocks" 
[4] $ gnuplot --version
    gnuplot 4.0 patchlevel 0


Best regards
Michal


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links