profile2.cpp

This sketch uses Profile and a packet handler to generate profile reports on demand that will be valid over days or weeks of runtime. The SFBProfile::getPPM method produces results from 0 to 1,000,000; dividing those values by 10,000 produces percentage figures. This sketch uses the QLED system to blink the LEDs and generate a bit of alarm handling load.

Typical output from this sketch in response to 'p' packets:

    p
    Ln 28.447 BG=97.97 SI=0.01 OI=1.60 PH=0.06 AH=0.35
    p
    Ln 37.321 BG=97.98 SI=0.01 OI=1.60 PH=0.05 AH=0.35
  
showing that nearly 98% of the time is assigned to 'background', and the next largest category is 'other interrupt' at 1.6%, followed by alarm handlers at 0.35% -- looks like QLED is just too efficient!

// Demonstrate the 'Profile' profiling object

// Report time percentages in all the built-in categories
void reportProfile(u8 *) {
  logNormal("BG=%f SI=%f OI=%f PH=%f AH=%f\n",
            Profile.getPPM(TICKER_BACKGROUND)/10000.0,
            Profile.getPPM(TICKER_SERIAL_ISR)/10000.0,
            Profile.getPPM(TICKER_OTHER_ISR)/10000.0,
            Profile.getPPM(TICKER_PACKET_HANDLER)/10000.0,
            Profile.getPPM(TICKER_ALARM_HANDLER)/10000.0);
}

void setup() {
  Profile.begin();              // Start the longer-term profiling system
  QLED.begin();                 // Let's use QLEDs to drive some alarm usage
  Body.reflex('p',reportProfile);
}

void loop() {

  // Spin the LEDs..
  for (u32 i = 0, f = NORTH; i <= 3; ++i, f = CLOCKWISE_FACE(f)) {
    QLED.off(pinInFace(FACE_LED_PIN,f),i*80);      // First, increasing off time
    QLED.on(pinInFace(FACE_LED_PIN,f),100);        // then same amount of blink time
    QLED.off(pinInFace(FACE_LED_PIN,f),(3-i)*80);  // then decreasing off time to even up
  }

  // ..once per second
  delay(1000);
}


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