home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-11-19 | 1.9 KB | 65 lines | [TEXT/MPS ] |
- /*
- File: TTimeExample.cp
-
- Contains: This module shows an example of how to use the TTime subclass.
-
- Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include "TInitSLM.h" // the TInitSLM class and SLM include files
-
- /*————————————————————————————————————————————————————————————————————————————————————
- main
-
- This examples uses a TTimeStamp to get the current the time, and then displays
- that time. It also uses the TStopWatch class to create delays of 4 seconds,
- 2 seconds, and 1 second.
- ————————————————————————————————————————————————————————————————————————————————————*/
-
- main()
- {
- TInitSLM initLibraryManager; // initialize the shared library manager
-
- if( initLibraryManager.Failed() ) // If we failed, let's go home
- return 1;
-
- // --------- example of TTimeStamp ---------
-
- TTimeStamp *timestamp = new TTimeStamp;
-
- if( !timestamp ) return 1; // make sure we didn't fail
-
- cout << "Time stamped at " << timestamp->GetMicroseconds() << " µsec\n" << endl;
- cout << "Time stamped at " << timestamp->GetMilliseconds() << " msec\n" << endl;
- cout << "Time stamped at " << timestamp->GetSeconds() << " sec\n" << endl;
-
- delete timestamp; // we are done with stopwatch
-
- // --------- example of TStopwatch ---------
-
- TStopwatch *stopwatch = new TStopwatch;
-
- if( !stopwatch ) return 1; // make sure we didn't fail
-
- cout << "waiting for 4000000 microseconds" << endl;
- stopwatch->Reset();
- while( stopwatch->ElapsedMicroseconds() < 4000000 );
- cout << "done *********" << endl;
-
- cout << "waiting for 2000 milliseconds" << endl;
- stopwatch->Reset();
- while( stopwatch->ElapsedMilliseconds() < 2000 );
- cout << "done *********" << endl;
-
- cout << "waiting for 1 second" << endl;
- stopwatch->Reset();
- while( stopwatch->ElapsedSeconds() < 1 );
- cout << "done *********" << endl;
-
- delete stopwatch; // we are done with TimeStamp
-
- return 0;
- }
-
-