home *** CD-ROM | disk | FTP | other *** search
- /*
- * This code illustrates how to create histogram and split histogram
- * statistic nodes and how to update their values.
- */
-
- #include "Instrumentation.h"
-
- #include <QuickDraw.h>
-
-
- OSStatus InitInstrumentation( void);
- void UpdateStatistics( SInt32 inputValue);
-
- InstHistogramClassRef gInputProfile;
- InstSplitHistogramClassRef gLowInputProfile;
-
-
- void main()
- {
- OSStatus err;
- int i;
-
- if ( noErr == ( err = InitInstrumentation()))
- {
- for ( i=0; i < 100; i++)
- UpdateStatistics( Random() % 100);
- }
- }
-
-
- OSStatus InitInstrumentation( void)
- /* Create and enable our statistics nodes. The counts are initially zero. */
- {
- OSStatus err;
-
- // The first histogram will have 20 buckets evenly distributed from 0-100.
- err = InstCreateHistogramClass( kInstRootClassRef, "Samples:Input Values",
- 0, 100, 20, kInstEnableClassMask, &gInputProfile);
-
- // Our second histogram will cover the same range, but "zoom in" on the values 0-10.
- if ( noErr == err)
- err = InstCreateSplitHistogramClass( kInstRootClassRef, "Samples:Low Input Values",
- 0, 10, 11, 100, 9, kInstEnableClassMask,
- &gLowInputProfile);
- return err;
- }
-
-
- void UpdateStatistics( SInt32 inputValue)
- /* Update the statistics with some new values. */
- {
- // Use the same call to update both types of histograms.
- InstUpdateHistogram( gInputProfile, inputValue, 1);
-
- InstUpdateHistogram( gLowInputProfile, inputValue, 1);
- }
-
-
-