Subject:
|
Re: Time a call to a function
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Tue, 9 Jan 2001 17:18:35 GMT
|
Viewed:
|
1571 times
|
| |
| |
On Tue, 9 Jan 2001, Athan Kostakos wrote:
> Hi,
> I am trying to determine the cpu time it takes to implement a number of
> additions and multiplications in a function, each time I call it, so to make
> it faster by improving the algorithm.
>
> It would be helpfull to display the result on the RCX lcd.
The global sys_time contains the number of milliseconds since... well,
since something. I think it's how long the RCX has been powered on since
the last firmware download. It's probably updated every millisecond. It's
a 32-bit number, so it won't overflow for almost 50 days.
So, what you can do is something like this:
long total_time;
long old_time = sys_time;
MyFunction();
total_time = sys_time - old_time;
And then you can do whatever you want with total_time, such as displaying
it on the LCD.
--
"Say not, 'I have found the truth,' but rather, 'I have found a truth.'
"Say not, 'I have found the path of the soul.' Say rather, 'I have met the
soul walking upon my path.'" -- Khalil Gibran
Mike Ash - <http://www.mikeash.com/>, <mailto:mail@mikeash.com>
|
|
Message is in Reply To:
| | Time a call to a function
|
| Hi, I am trying to determine the cpu time it takes to implement a number of additions and multiplications in a function, each time I call it, so to make it faster by improving the algorithm. It would be helpfull to display the result on the RCX lcd. (24 years ago, 9-Jan-01, to lugnet.robotics.rcx.legos)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|