Import upstream u-boot 1.1.4
[u-boot.git] / board / MAI / bios_emulator / scitech / src / pm / tests / timercpp.cpp
1 /****************************************************************************
2 *
3 *                   SciTech OS Portability Manager Library
4 *
5 *  ========================================================================
6 *
7 *    The contents of this file are subject to the SciTech MGL Public
8 *    License Version 1.0 (the "License"); you may not use this file
9 *    except in compliance with the License. You may obtain a copy of
10 *    the License at http://www.scitechsoft.com/mgl-license.txt
11 *
12 *    Software distributed under the License is distributed on an
13 *    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 *    implied. See the License for the specific language governing
15 *    rights and limitations under the License.
16 *
17 *    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
18 *
19 *    The Initial Developer of the Original Code is SciTech Software, Inc.
20 *    All Rights Reserved.
21 *
22 *  ========================================================================
23 *
24 * Language:     C++ 3.0
25 * Environment:  Any
26 *
27 * Description:  Test program for the Zen Timer Library C++ interface.
28 *
29 ****************************************************************************/
30
31 #include <iostream.h>
32 #include "pmapi.h"
33 #include "ztimer.h"
34
35 /*-------------------------- Implementation -------------------------------*/
36
37 int     i,j,k;                              /* NON register variables! */
38
39 void dummy() {}
40
41 int main(void)
42 {
43     LZTimer     ltimer;
44     ULZTimer    ultimer;
45
46     ZTimerInit();
47
48     /* Test the long period Zen Timer (we don't check for overflow coz
49      * it would take tooooo long!)
50      */
51
52     cout << endl;
53     ultimer.restart();
54     ltimer.start();
55     for (j = 0; j < 10; j++)
56         for (i = 0; i < 20000; i++)
57             dummy();
58     ltimer.stop();
59     ultimer.stop();
60     cout << "LCount:  " << ltimer.count() << endl;
61     cout << "Time:    " << ltimer << " secs\n";
62     cout << "ULCount: " << ultimer.count() << endl;
63     cout << "ULTime:  " << ultimer << " secs\n";
64
65     cout << endl << "Timing ... \n";
66     ultimer.restart();
67     ltimer.restart();
68     for (j = 0; j < 200; j++)
69         for (i = 0; i < 20000; i++)
70             dummy();
71     ltimer.stop();
72     ultimer.stop();
73     cout << "LCount:  " << ltimer.count() << endl;
74     cout << "Time:    " << ltimer << " secs\n";
75     cout << "ULCount: " << ultimer.count() << endl;
76     cout << "ULTime:  " << ultimer << " secs\n";
77
78     /* Test the lap function of the long period Zen Timer */
79
80     cout << endl << "Timing ... \n";
81     ultimer.restart();
82     ltimer.restart();
83     for (j = 0; j < 20; j++) {
84         for (k = 0; k < 10; k++)
85             for (i = 0; i < 20000; i++)
86                 dummy();
87         cout << "lap: " << ltimer.lap() << endl;
88         }
89     ltimer.stop();
90     ultimer.stop();
91     cout << "LCount:  " << ltimer.count() << endl;
92     cout << "Time:    " << ltimer << " secs\n";
93     cout << "ULCount: " << ultimer.count() << endl;
94     cout << "ULTime:  " << ultimer << " secs\n";
95
96 #ifdef  LONG_TEST
97     /* Test the ultra long period Zen Timer */
98
99     ultimer.start();
100     delay(DELAY_SECS * 1000);
101     ultimer.stop();
102     cout << "Delay of " << DELAY_SECS << " secs took " << ultimer.count()
103          << " 1/10ths of a second\n";
104     cout << "Time: " << ultimer << " secs\n";
105 #endif
106     return 0;
107 }