View Single Post
  #6   Spotlight this post!  
Unread 21-01-2013, 01:28
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is online now
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: SetSafetyEnabled() and SetExpiration()

If you really have a laggy problem and are trying to figure out what is taking all the time, there are a number of tactics to take. One tactic that can be helpful is getting quantitative values that show "how much time does this part take?" Without a good professional profiler, you can use the 'old school' method of timing...usually you will have a good sense of what's taking all the time - like vision code processing takes a lot of time. Get a value...

I'd suggest something like:
Code:
int loopstart, loopend, videostart, videoend;
while (IsOperatorControl())
{
  loopstart = GetUsClock(); // microseconds since startup

 [ code code code ]
  // start of vision code
  videostart = GetUsClock(); // microseconds since startup
  ProcessImage();
  videoend = GetUsClock(); // microseconds since startup
[ code code code ]
  loopend = GetUsClock(); // microseconds since startup
  SmartDashboard::PutNumber("LoopTime-ms", (loopend-loopstart)/1000);
  SmartDashboard::PutNumber("VideoTime-ms", (videoend-videostart)/1000);
  
}
The gist here is to get an idea of at least two things -- how long does it take you to loop the loop and how long does your "big possible offender" take to run? In SmartDashboard, you can have these values plotted as a graph rather than as just numbers "flitting" on the dashboard. That helps to see if you have consistent results or if your processing is for some reason sporatic.
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote