FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you tell what loops are eating up CPU time?

Solved!
Go to solution

While debuggin something else, I would watch CPU usage on the charts screen of the driver station. With the gyro in, we were consistantly at 100%. When it was commented out, we dropped back to 80%. However, I had to find this out through trial and error. I commented out different loops in periodic tasks until I found it. Is there an easier way to find the CPU hog rather than trial and error?

"Lockheed" Joe
Testing Blog"
0 Kudos
Message 1 of 4
(3,937 Views)
Solution
Accepted by topic author LockheedJoe

With just the tools for FRC the best way to is strategically benchmark your code - divide the code in half bench mark each half, divide each part in half again.  You can also use this tool:http://sine.ni.com/nips/cds/view/p/lang/en/nid/209041 (there is a 30 day trial)

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 2 of 4
(2,858 Views)

Thanks

"Lockheed" Joe
Testing Blog"
0 Kudos
Message 3 of 4
(2,858 Views)

Another thing to note in all of this debugging is that running the code in interactive mode (with all the front panels updating) takes more resources than running the executable so if you want to do true debugging of how it is going to behave at competition you should do the debug of the compiled executable running on the cRIO. Thats harder to do since you don't have the instant feedback of the sensors but you can do things like write the time the loop is taking to a network shared variable - or broadcast over UDP (sparingly).

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 4 of 4
(2,858 Views)