1 /*---------------------------------------------------------------------------*
2   Project:  Dolphin OS Overview - Stopwatch demo
3   File:     stopwatchdemo.c
4 
5   Copyright 1998, 1999 Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Log: stopwatchdemo.c,v $
14   Revision 1.2  02/20/2006 04:13:11  mitu
15   changed include path from dolphin/ to revolution/.
16 
17   Revision 1.1  01/13/2006 11:24:13  hiratsu
18   Initial check in.
19 
20 
21     1     6/04/99 3:04p Tianli01
22     Initial check-in
23   $NoKeywords: $
24  *---------------------------------------------------------------------------*/
25 
26 /*---------------------------------------------------------------------------*
27   This program times how long a matrix concatenation takes
28  *---------------------------------------------------------------------------*/
29 
30 #include <revolution.h>
31 
32 #define OUTER_ITERATIONS  50
33 #define INNER_ITERATIONS  100
34 
35 OSStopwatch         MySW;
36 
main(void)37 void main (void)
38 {
39     u32             i, j;
40     Mtx             a, b, ab;
41 
42     OSInit();
43 
44     OSReport("\n-----------------------------------");
45     OSReport("\n  Hit Command+Q to quit this demo");
46     OSReport("\n-----------------------------------\n\n");
47 
48     OSInitStopwatch(&MySW, "100 concat stopwatch");
49     OSReport("Stopwatch demo program\nTimes %d matrix concatenations\n",
50              OUTER_ITERATIONS*INNER_ITERATIONS);
51 
52     MTXIdentity(a);
53     MTXIdentity(b);
54     MTXIdentity(ab);
55 
56     for (i = 0; i < OUTER_ITERATIONS; i++)
57     {
58         OSStartStopwatch(&MySW);
59         for (j = 0; j < INNER_ITERATIONS; j++)
60         {
61             MTXConcat(a, b, ab);
62         }
63         OSStopStopwatch(&MySW);
64     }
65     OSReport("\nEach hit is 100 matrix concats:\n");
66     OSDumpStopwatch(&MySW);
67     OSHalt("Stopwatch Demo complete");
68 }
69