home *** CD-ROM | disk | FTP | other *** search
- /*
- * This code illustrates how to create trace nodes and log trace events to them.
- */
-
- #include "Instrumentation.h"
-
-
- OSStatus InitInstrumentation( void);
- void LogTraces( void);
-
- InstTraceClassRef gTraceRef,
- gTraceWithDataRef;
-
- InstDataDescriptorRef gDataDesc;
-
-
- void main()
- {
- OSStatus err;
-
- if ( noErr == ( err = InitInstrumentation()))
- LogTraces();
- }
-
-
- OSStatus InitInstrumentation( void)
- /* Create and enable our trace instrumentation nodes. */
- {
- OSStatus err;
-
- err = InstCreateTraceClass( kInstRootClassRef, "Samples:Trace 1", 'samp',
- kInstEnableClassMask, &gTraceRef);
-
- if ( noErr == err)
- err = InstCreateTraceClass( kInstRootClassRef, "Samples:Trace 2", 'samp',
- kInstEnableClassMask, &gTraceWithDataRef);
-
- if ( noErr == err)
- err = InstCreateDataDescriptor( "%ld", &gDataDesc);
-
- return err;
- }
-
-
- void LogTraces( void)
- /* Log some traces. */
- {
- InstEventTag tag;
- UInt32 result;
-
- tag = InstCreateEventTag(); // or any other relatively unique 32-bit value
-
- // log the start time of the routine
- InstLogTraceEvent( gTraceRef, tag, kInstStartEvent);
-
- // do some time-consuming processing here
- // result = foo();
-
- // record the result as a trace
- InstLogTraceEventWithData( gTraceWithDataRef, kInstNoEventTag, kNilOptions, gDataDesc, result);
-
- // log the end time of the routine
- InstLogTraceEvent( gTraceRef, tag, kInstEndEvent);
- }
-
-
-