# The Value of Integral Counters

The Intel® Energy Checker (Intel® EC) SDK provides simple mechanisms to import and export measures of "useful work". For an e-mail application, this could be things like the following:

• Number of e-mails sent
• Number of bytes in sent e-mails
• Number of bytes in received e-mails
• Number of e-mail messages deleted
• etc.

The examples above are all finite elements/events that can be easily measured and counted. However there are many physical measurements more closely relating to rates than finite events:

• Speed (miles per hour, kilometers per hour, feet per second, etc.)
• Power (Watts)
• Temperature (degrees Fahrenheit, Celsius, or Kelvin)
• Weight (pounds, kilograms, or tons)
• Brightness (lumens)

Speed is a measure of how fast something is going, not how far it has traveled; distance is an integral of speed over time. Similarly, energy is the integration of power over time, and you pay the electric utility company for the energy you consume.

If you want to compute the average speed over a 4-hour drive, you can record the speed every second during that 4-hour period, sum up the speeds for each second, and then divide by the number of seconds elapsed during the drive. Alternatively, you can use the integral distance counter included in each car (the odometer): record the odometer reading and time at the start of the trip, record the odometer reading and time at the end of the trip, and divide the elapsed distance by the elapsed time. This second method is much less work and also less prone to measurement errors.

Determining average temperature throughout a test can accomplished in a similar manner. The TSRV (temperature server) utility included with the Intel® Energy Checker SDK provides the ability to measure temperature from supported temperature devices. TSRV records temperature in Kelvin to avoid potential complications with combinations of positive and negative temperatures: 0°C = 273.15 Kelvin, which TSRV would record as 27315, since it records temperature in hundredths of Kelvin. TSRV also provides an integral counter in Kelvin-seconds; a constant 25°C room would cause a Kelvin-second counter to increase by 29815 ((273.15 + 25) * 100) every second: 29815, 59630, 89445, etc. When running a test, you can record the Kelvin-seconds counter and the time at the beginning and end of the test and divide the difference in Kelvin-seconds by the elapsed time in seconds to get the average reading. While being both easier and more accurate than trying to read the TSRV instantaneous value every second, this approach has the added benefit of being more energy efficient: test software doesn't waste time gathering intermediate data it doesn't need.

An additional benefit of this approach is that allows an arbitrary number of overlapping averages to be computed without complicating the application maintaining the counter. For example, if there was a need for test software to calculate running average temperatures every 12 seconds, every 30 seconds, and every 45 seconds, TSRV doesn't have to change; TSRV just has to maintain one integral temperature counter, and the management software can sample that counter at whatever frequency it needs. The management software records the counter values and computes averages from these integral counters as necessary.

Integral counters can be applied to various sensors and rates. For example, to determine the average weight of people on a hotel catwalk throughout a day, it's not sufficient to simply measure the weight of each person who enters the catwalk, because you need to know the weight of all the people on the catwalk at any given time. You could continuously record the weight of people on the catwalk each second and add that value to a kilogram-seconds integral counter. To find the average load on the catwalk from 8am to 9am, record the kilogram-seconds counter at each of these times and divide the difference in these values by the 3600 seconds in an hour.

Similarly, you could record average luminosity in a room with an instrument to measure luminous flux in lumens and then accumulating these luminosity values in a lumens-seconds integral counter.

The concept of integral counters is not limited to physical sensors. For example, in the e-mail example at the start of this blog entry, another measure could have been the number of users with active e-mail sessions. If it's important to capture the number of seconds that each user is actively maintaining a mail server connection, you could develop an active_sessions-seconds integral counter; the application could add the number of active users each second. An administrator wanting to determine busy periods for the mail server could sample the active_sessions-seconds counter every fifteen minutes. A separate program used for long-term trending could sample this same counter every hour without the mail server needing to change.

Integral counters are a useful concept for trending and analysis using the Intel® Energy Checker SDK.

--kb

For more complete information about compiler optimizations, see our Optimization Notice.
Categories:
Tags: