Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] A Rich Experiment Indeed
- Date: Sun, 4 Dec 2005 14:37:16 -0500
- From: Jim <jep200404@example.com>
- Subject: Re: [tlug] A Rich Experiment Indeed
- References: <20051202154627.GB4348@example.com> <20051202152527.302e2f6f.jep200404@example.com> <20051203122655.GG4348@example.com> <20051203092314.3118db01.jep200404@example.com> <20051204100726.GH4348@example.com>
Michal Hajek wrote: > [W]ell, I have been reading more and trying to understand. You are succeeding quite well. This is fun. Thanks for the ride. > 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. > 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 > [Data plotted] 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! Ahh, so now I know the Czech translation of "Yikes!". > Even though Jim did not use gettimeofday(), his program gives more or > less straight line, while Josh's noname gives a saw. > > ... Josh's programm :... > 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); > ^^^^^ ^^^^^^^^^ Excellent, your vision is excellent. > 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 [a somewhat good result] :) Cool! I would remove the unnecessary int cast: printf("%ld.%06ld \t \n",start.tv_sec,start.tv_usec); Now to polish to a high sheen, removing the need for my crude sed trimming: $ cat chronos.c #include <stdio.h> #include <stdlib.h> #include <sys/time.h> int main(int argc,char *argv[]) { struct timeval start; struct timeval now; gettimeofday(&start,NULL); for (;;) { gettimeofday(&now,NULL); printf("%ld.%06ld\n",now.tv_sec-start.tv_sec,now.tv_usec); } return EXIT_SUCCESS; } $ make chronos cc chronos.c -o chronos $ ./chronos >chronos.dat ^C (this abrupt end can leave in incomplete line. You can delete the incomplete line, or leave it as a "flyer" point. (So much for high sheen.)) $ gnuplot gnuplot> plot 'chronos.dat' > ... gnuplot [4] is able to handle mouse clicks > inside graph and some manipulation based on mouse input. > If anyone has a good totorial page, it would be [welcome]. Welcome by me too. I used the http://www.duke.edu/~hpgavin/gnuplot.html tutorial, but I don't think it covers mouse stuff. Sometimes you just have to break down and read the official manual. http://www.gnuplot.info/docs/gnuplot.html A Rich Experiment Indeed
- References:
- [tlug] timing for geeks :)
- From: Michal Hajek
- Re: [tlug] timing for geeks
- From: Jim
- Re: [tlug] timing for geeks
- From: Michal Hajek
- Re: [tlug] A Rich Experiment Indeed
- From: Jim
- Re: [tlug] A Rich Experiment Indeed
- From: Michal Hajek
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Japanese keyboards, illustrated
- Next by Date: Re: [tlug] Mea Culpa
- Previous by thread: Re: [tlug] timing for geeks II.
- Next by thread: [tlug] US keyboards
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links