summaryrefslogtreecommitdiffstats
path: root/private/oleutest/perform/cairole/tests/bm_iid.cxx
blob: d7e63493c10f4cd60f667fafac4f4ec25dbad5e4 (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
109
110
//+------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1993.
//
//  File:	bm_iid.cxx
//
//  Contents:	compare inline vs function call for guid compares
//
//  Classes:	CGuidCompareTest
//
//  History:    1-July-93 t-martig    Created
//
//--------------------------------------------------------------------------
#include <headers.cxx>
#pragma hdrstop

#include <bm_iid.hxx>
#include <oletest.hxx>


TCHAR *CGuidCompareTest::Name ()
{
    return TEXT("GuidCompare");
}


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

    //	get iteration count
    m_ulIterations = pInput->GetIterations(Name());

    //	initialize state
    INIT_RESULTS(m_ulRepFunctionNEQTime);
    INIT_RESULTS(m_ulRepFunctionEQTime);
    INIT_RESULTS(m_ulRepInlineNEQTime);
    INIT_RESULTS(m_ulRepInlineEQTime);

    return S_OK;
}


SCODE CGuidCompareTest::Cleanup ()
{	
    return S_OK;
}


SCODE CGuidCompareTest::Run ()
{
	CStopWatch  sw;
	BOOL	    fRslt;

	//  compute times for the function version
	for (ULONG iIter=0; iIter<m_ulIterations; iIter++)
	{
	    sw.Reset();
	    for (ULONG j=0; j<1000; j++)
		fRslt = IsEqualIID(IID_IUnknown, IID_IClassFactory);
	    m_ulRepFunctionNEQTime[iIter] = sw.Read();
	}
	for (iIter=0; iIter<m_ulIterations; iIter++)
	{
	    sw.Reset();
	    for (ULONG j=0; j<1000; j++)
		fRslt = IsEqualIID(IID_IUnknown, IID_IUnknown);
	    m_ulRepFunctionEQTime[iIter] = sw.Read();
	}

	//  compute the time for the inline
	for (iIter=0; iIter<m_ulIterations; iIter++)
	{
	    sw.Reset();
	    for (ULONG j=0; j<1000; j++)
		fRslt = !memcmp((void *)&IID_IUnknown,
				(void *)&IID_IClassFactory, sizeof(GUID));
	    m_ulRepInlineNEQTime[iIter] = sw.Read();
	}
	for (iIter=0; iIter<m_ulIterations; iIter++)
	{
	    sw.Reset();
	    for (ULONG j=0; j<1000; j++)
		fRslt = !memcmp((void *)&IID_IUnknown,
				(void *)&IID_IUnknown, sizeof(GUID));
	    m_ulRepInlineEQTime[iIter] = sw.Read();
	}

	return S_OK;
}					  



SCODE CGuidCompareTest::Report (CTestOutput &output)
{
    output.WriteSectionHeader (Name(), TEXT("GUID Compare"), *m_pInput);

    output.WriteResults (TEXT("\nIsEqualGUID Not Equal x 1000 "),
		m_ulIterations, m_ulRepFunctionNEQTime);
    output.WriteResults (TEXT("\nIsEqualGUID Equal x 1000 "),
                m_ulIterations, m_ulRepFunctionEQTime);

    output.WriteResults (TEXT("memcmp Not Equal x 1000        "),
		m_ulIterations, m_ulRepInlineNEQTime);
    output.WriteResults (TEXT("memcmp Equal x 1000        "),
                m_ulIterations, m_ulRepInlineEQTime);

    return S_OK;
}