Subject:
|
Re: IC Timing
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Sat, 27 Apr 1996 18:48:06 GMT
|
Original-From:
|
Brian Peter Schmalz <CSC_SCHMALZB@saynotospamLAWRENCE.EDU>
|
Viewed:
|
1996 times
|
| |
| |
> How do you time a running process? I would like to prune the running time
> of a part of my IC program running in the HandyBoard, to improve the
> response of my sensor testing. I assume you could set a clock and then
> sample it later but I am a little weak in 'C' and very new to the 68HC11.
I don't know if this is really the best way to do it, but I hacked this up
real quick for a previous project.
You put the stuff you want to time inside the loop. It will print out the
numer of times the loop executes per second. The display is updated every
4th time through the loop, if you have something that's changing rapidly and
you want to see what it is, put it in the printf() call and set the 4.0 and 4
to whatever you want. If you only want to time the loop, it would be better if
you took the printf() and put in the first if{} construct.
I hope this is what you watned- :-)
int loopnum, iterations;
float start_time, end_time;
start_time = seconds();
end_time = start_time+1.0;
iterations = 0;
loopnum = 0;
while(!stop_button()) {
if (seconds() >= end_time) {
start_time = seconds();
end_time = start_time+1.0;
iterations = loopnum;
loopnum = 0;
}
loopnum = loopnum + 1;
if (((float)loopnum/4.0) - (float)(loopnum/4) == 0.0) {
printf("%d\n",iterations);
}
/* Put the rest of your loop here */
}
*Brian Schmalz
/--------------------+---------------------\
| Brian Schmalz | Building autonomous |
| 723 E. John Street | LEGO robots at |
| Appleton, WI | Lawrence University |
| 54911 | (414)832-6655 |
+---------------------+----------------------+
| Brian.P.Schmalz@Lawrence.edu |
| http://www.lawrence.edu/~schmalzb |
\------------------------------------------/
|
|
Message is in Reply To:
| | IC Timing
|
| How do you time a running process? I would like to prune the running time of a part of my IC program running in the HandyBoard, to improve the response of my sensor testing. I assume you could set a clock and then sample it later but I am a little (...) (29 years ago, 27-Apr-96, to lugnet.robotics.handyboard)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|