summaryrefslogtreecommitdiffstats
path: root/private/oleutest/perform/cairole/tests/bm_noise.cxx
blob: 7759334ea0a969fe154dd0da2a0b618a5e83f7fe (plain) (blame)
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
104
105
106
107
108
//+------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1993.
//
//  File:	    bm_noise.cxx
//
//  Contents:	output class for benchmark results
//
//  Classes:	CNoiseTest
//
//  History:    30-June-93 t-martig    Created
//
//--------------------------------------------------------------------------
#include <headers.cxx>
#pragma hdrstop

#include <bm_noise.hxx>



TCHAR *CNoiseTest::Name ()
{
    return TEXT("Noise Test");
}


SCODE CNoiseTest::Setup (CTestInput *pInput)
{
    CTestBase::Setup(pInput);

    //	get iteration count
    m_ulIterations = pInput->GetIterations(Name(), TEST_MAX_ITERATIONS);
    INIT_RESULTS(m_ulNoiseTime);
    return S_OK;
}


SCODE CNoiseTest::Run ()
{
	CStopWatch sw;
	int n;
	FILE *pfDump;
	char buffer[100];
	int i;

	m_ulResolution = sw.Resolution();

	sw.Reset();
	Sleep (1000);
	m_ulSleep = sw.Read();

	sw.Reset();
	for (n=0; n<10000; n++);
	m_ulIdle = sw.Read();

	for (ULONG iIter=0; iIter<m_ulIterations; iIter++)
	{
        sw.Reset();
        m_ulNoiseTime[iIter] = sw.Read();
	}

	pfDump = fopen ("C:\\DUMP.BM", "wb");
	if (pfDump)
	{
		sw.Reset();
		for (i=0; i<1000; i++)
			fwrite (&buffer, 1, 100, pfDump);
		m_ulDumpWrite = sw.Read();
		fclose (pfDump);

		pfDump = fopen ("C:\\DUMP.BM", "rb");
		if (pfDump)
		{
			sw.Reset();
			for (i=0; i<1000; i++)
				fread (&buffer, 1, 100, pfDump);
			m_ulDumpRead = sw.Read();
			fclose (pfDump);
		}
		else
			m_ulDumpRead = 0xffffffff;
		
		_unlink ("C:\\DUMP.BM");
	}
	else
		m_ulDumpWrite = 0xffffffff;

	return S_OK;
}					



SCODE CNoiseTest::Report (CTestOutput &output)
{
    output.WriteSectionHeader (Name(), NULL, *m_pInput);

    output.WriteResult (TEXT("Resolution"), m_ulResolution);
    output.WriteResult (TEXT("Sleep 1000ms"), m_ulSleep);
    output.WriteResult (TEXT("Idle 10000 loops"), m_ulIdle);
    output.WriteResults (TEXT("Noise"), m_ulIterations, m_ulNoiseTime);
    output.WriteResult (TEXT("Write 100k to disk"), m_ulDumpWrite);
    output.WriteResult (TEXT("Read 100k from disk"), m_ulDumpRead);

    return S_OK;
}