print.c
2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*====================================================================
* print.c
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: print.c,v $
$Revision: 1.1.1.1 $
$Date: 2002/05/02 03:27:33 $
*---------------------------------------------------------------------*/
/*
* print - measure the performance of osSyncPrintf, with and without the osRdbInit call
*
*/
#include <ultra64.h>
#include "print.h"
OSThread idleThread;
OSThread mainThread;
u64 bootStack[STACKSIZE/8];
u64 idleThreadStack[STACKSIZE/8];
u64 mainThreadStack[STACKSIZE/8];
void idleproc(void *arg);
void mainproc(void *arg);
#define RDBSENDBUF_SIZE 0x8000
u8* rdbSendBuf[RDBSENDBUF_SIZE];
boot(void *arg)
{
int i;
char *ap;
u32 *argp;
u32 argbuf[16];
osInitialize();
osCreateThread(&idleThread, 1, idleproc, arg,
(void *)(idleThreadStack+STACKSIZE/8),
(OSPri) OS_PRIORITY_IDLE);
osStartThread(&idleThread);
}
void idleproc(void *arg)
{
osCreateThread(&mainThread, 6, mainproc, arg,
mainThreadStack+STACKSIZE/8, (OSPri) 10);
osStartThread(&mainThread);
while (1);
}
void mainproc(void* arg)
{
OSTime start_time1;
OSTime start_time2;
OSTime elapsed_time2;
OSTime start_time3;
OSTime elapsed_time3;
int i;
start_time2 = osGetTime();
for (i = 0; i < TIMES; i++)
osSyncPrintf("osSyncPrintf %d\n",i);
elapsed_time2 = osGetTime() - start_time2;
osInitRdb((char*)rdbSendBuf,RDBSENDBUF_SIZE);
start_time1 = osGetTime();
while(( osGetTime() - start_time1) < 0x8000000);
start_time3 = osGetTime();
for (i = 0; i < TIMES; i++)
osSyncPrintf("osSyncPrintf %d\n",i);
elapsed_time3 = osGetTime() - start_time3;
start_time1 = osGetTime();
while(( osGetTime() - start_time1) < 0x8000000);
osSyncPrintf("osSyncPrintf without osInitRdb = %llu ns\n", OS_CYCLES_TO_NSEC(elapsed_time2 / TIMES));
osSyncPrintf("osSyncPrintf with osInitRdb = %llu ns\n", OS_CYCLES_TO_NSEC(elapsed_time3 / TIMES));
while(1);
}