Is there high precision (millisecond) CLI stop watch in Ubuntu?

link|improve this question

sudo aptitude install stopwatch – Josh K Jul 14 '10 at 2:13
I would use it to measure the interval between two signals from RS232 devices. I know how to write C program, but I'd like to know if there is already the utility. – Xie Jilei Jul 14 '10 at 2:13
@Josh: Have you tried using that in a Command Line User Environment (CLUE, as in "get a clue" :P) or Command Line Interface (the CLI requested here). – Roger Pate Jul 14 '10 at 5:01
@Roger: Yes I did. Considering I have almost every known package repository added it dutifully informed me there were several choices to pick from. Alas I didn't write them down and suffered a fatal system crash a short while later. – Josh K Jul 14 '10 at 5:32
1  
@Josh: apt-cache show stopwatch will list the latest version from each repository in which it's available. Or just repeat the steps you did above and write down the choices it dutifully informs you of. – Roger Pate Jul 14 '10 at 18:49
show 2 more comments
feedback

1 Answer

up vote 1 down vote accepted

If you want to program it in C, then you want to be looking at the gettimeofday(2) function. This returns a structure which contains a time_t (accurate to the nearest second), and a tv_usec (accurate to the nearest microsecond). By doing two of these, and appropriate math, you can get the interval. Note that even though the systemcall returns microseconds, you can't get an interval that small. The actual resolution can be seen in /proc/timer_list.

Of course, a programing question would be better on stackoverflow.

link|improve this answer
Did I misunderstand the question? He doesn't want to write his own program in C. – Roger Pate Jul 14 '10 at 4:55
According to the OP's comment, that is one of the options he is considering to solve the problem. – Groo Jul 14 '10 at 6:52
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.