profile1.cpp

This sketch uses Ticker to measure how time is spent during ten second time windows. Each time through the loop() function, first Ticker is reset, then a ten second delay is performed, and then the total number of microseconds assigned to various categories during that delay are reported.

Typical output from this sketch, when running on an isolated cell (connected only via USB-serial to sfbprog), is:

    143 2477 9837132
    119 2465 9837152
    182 2308 9837263
  
while typical output from this sketch running on a cell that is connected to another cell, and also via USB-serial, is:
    339 1767 9837721
    239 1684 9837964
    250 1682 9837980
  

Note that packet-handling time rises a bit, which makes sense, but that alarm load actually decreases! Why? It turns out, because 'test packets' are sent on inactive faces to check for connections more often than 'keep-alive packets' are sent on active faces!

// Demonstrate the low-level 'Ticker' profiler
//
// Note that in many cases the 'Profile' object is more useful than
// the 'Ticker' object, but since Profile is built on top of Ticker,
// the latter is shown first.

void setup() {
  // Nothing to do
}

void loop() {
  Ticker.reset();       // Reset low-level counters
  delay(10*1000);       // Wait ten seconds to collect some data
  pprintf("%d %d %d\n", // Report microseconds in selected categories --
          Ticker.getUsec(TICKER_PACKET_HANDLER),  // packet handling
          Ticker.getUsec(TICKER_ALARM_HANDLER),   // alarm handling
          Ticker.getUsec(TICKER_BACKGROUND));     // loop, etc
  delay(200);           // Wait a bit for that output to ship..
}

Generated on Fri Apr 22 06:54:11 2011 for SFB by doxygen 1.5.9