# SFBProfile Class Reference

A profiling system providing millisecond resolution for over a month's worth of runtime. More...

`#include <SFBTicker.h>`

## Public Member Functions
u32 | getMsec (u32 tickerCode)
| Return the number of milliseconds assigned to tickerCode.
u32 | getPPM (u32 tickerCode)
| Return the fraction of time assigned to tickerCode, in parts per million.
u32 | getTotalMsec ()
| Return the total number of milliseconds since the (last) call on begin.
void | begin ()
| Initialize or reinitialize the system, clearing all counts.
void | end ()
| Stop the SFBProfile system.
## Friends
void | updateProfile (u32 when, void *arg)

## Detailed Description

A profiling system providing millisecond resolution for over a month's worth of runtime.

Note that unlike Ticker, which is an integral part of the core software, use of this SFBProfile class (via its associated object Profile) is optional, and it will not be included in builds unless your sketch code refers to it. If you do make use of the Profile, it will cost you 40 bytes of RAM and one alarm from the Alarms pool.

To initialize the system, just call `Profile.begin()` from the setup() function. The begin() method can be called again to clear and reinitialize the SFBProfile if desired, to get 'fresh statistics' (or if your sketch runtime is exceeding about a month).

While the Profile is running, it will automatically gather data from the Ticker as needed. In addition, the Profile automatically resets the Ticker about every half hour, to keep it from overflowing. Consequently, while the Profile is being used, the sketch must not call SFBTicker::reset() itself, and calls to SFBTicker::getUsec() will return values relative to the time of the last Profile-induced reset.

The sketch may call end() to deactivate the SFBProfile system prior to interacting directly with the Ticker.

## Member Function Documentation

void SFBProfile::end | ( |  | ) |

Stop the SFBProfile system.

When stopped, the SFBProfile system will not reset the Ticker object, so it can safely be manipulated by direct SFBTicker calls.

u32 SFBProfile::getMsec | ( | u32 | tickerCode | ) |

Return the number of milliseconds assigned to tickerCode.

This value may be inaccurate if more than forty-nine days have elapsed since the (last) call on begin().

Parameters:

  | tickerCode | The SFBTickerCategories category to access.

Blinks:
  E_API_MAX_RANGE if category is not one of the SFBTickerCategories values, 0..MAX_TICKERS-1

u32 SFBProfile::getPPM | ( | u32 | tickerCode | ) |

Return the fraction of time assigned to tickerCode, in parts per million.

This value may be inaccurate if more than forty-nine days have elapsed since the (last) call on begin().

This value can be turned into a percentage by dividing by 10,000. Calling getPPM() on all categories and summing the results will generally produce a value slightly smaller than 1,000,000, due to truncation.

Parameters:

  | tickerCode | The SFBTickerCategories category to access.

Returns:
  a number from 0 to 1,000,000 representing how many millionths of the total time were assigned to this category.

Blinks:
  E_API_MAX_RANGE if category is not one of the SFBTickerCategories values, 0..MAX_TICKERS-1

Examples:
  profile2.cpp, profile3.cpp, and speed4.cpp.

u32 SFBProfile::getTotalMsec | ( |  | ) |

Return the total number of milliseconds since the (last) call on begin.

This value will be inaccurate if more than about forty-nine days have elapsed since the last begin().

The documentation for this class was generated from the following files:

- src/include/SFBTicker.h
- src/components/library/SFBTicker.cpp