Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
2.7 KiB

  1. //+------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993.
  5. //
  6. // File: bm_iid.cxx
  7. //
  8. // Contents: compare inline vs function call for guid compares
  9. //
  10. // Classes: CGuidCompareTest
  11. //
  12. // History: 1-July-93 t-martig Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #include <headers.cxx>
  16. #pragma hdrstop
  17. #include <bm_iid.hxx>
  18. #include <oletest.hxx>
  19. TCHAR *CGuidCompareTest::Name ()
  20. {
  21. return TEXT("GuidCompare");
  22. }
  23. SCODE CGuidCompareTest::Setup (CTestInput *pInput)
  24. {
  25. CTestBase::Setup(pInput);
  26. // get iteration count
  27. m_ulIterations = pInput->GetIterations(Name());
  28. // initialize state
  29. INIT_RESULTS(m_ulRepFunctionNEQTime);
  30. INIT_RESULTS(m_ulRepFunctionEQTime);
  31. INIT_RESULTS(m_ulRepInlineNEQTime);
  32. INIT_RESULTS(m_ulRepInlineEQTime);
  33. return S_OK;
  34. }
  35. SCODE CGuidCompareTest::Cleanup ()
  36. {
  37. return S_OK;
  38. }
  39. SCODE CGuidCompareTest::Run ()
  40. {
  41. CStopWatch sw;
  42. BOOL fRslt;
  43. // compute times for the function version
  44. for (ULONG iIter=0; iIter<m_ulIterations; iIter++)
  45. {
  46. sw.Reset();
  47. for (ULONG j=0; j<1000; j++)
  48. fRslt = IsEqualIID(IID_IUnknown, IID_IClassFactory);
  49. m_ulRepFunctionNEQTime[iIter] = sw.Read();
  50. }
  51. for (iIter=0; iIter<m_ulIterations; iIter++)
  52. {
  53. sw.Reset();
  54. for (ULONG j=0; j<1000; j++)
  55. fRslt = IsEqualIID(IID_IUnknown, IID_IUnknown);
  56. m_ulRepFunctionEQTime[iIter] = sw.Read();
  57. }
  58. // compute the time for the inline
  59. for (iIter=0; iIter<m_ulIterations; iIter++)
  60. {
  61. sw.Reset();
  62. for (ULONG j=0; j<1000; j++)
  63. fRslt = !memcmp((void *)&IID_IUnknown,
  64. (void *)&IID_IClassFactory, sizeof(GUID));
  65. m_ulRepInlineNEQTime[iIter] = sw.Read();
  66. }
  67. for (iIter=0; iIter<m_ulIterations; iIter++)
  68. {
  69. sw.Reset();
  70. for (ULONG j=0; j<1000; j++)
  71. fRslt = !memcmp((void *)&IID_IUnknown,
  72. (void *)&IID_IUnknown, sizeof(GUID));
  73. m_ulRepInlineEQTime[iIter] = sw.Read();
  74. }
  75. return S_OK;
  76. }
  77. SCODE CGuidCompareTest::Report (CTestOutput &output)
  78. {
  79. output.WriteSectionHeader (Name(), TEXT("GUID Compare"), *m_pInput);
  80. output.WriteResults (TEXT("\nIsEqualGUID Not Equal x 1000 "),
  81. m_ulIterations, m_ulRepFunctionNEQTime);
  82. output.WriteResults (TEXT("\nIsEqualGUID Equal x 1000 "),
  83. m_ulIterations, m_ulRepFunctionEQTime);
  84. output.WriteResults (TEXT("memcmp Not Equal x 1000 "),
  85. m_ulIterations, m_ulRepInlineNEQTime);
  86. output.WriteResults (TEXT("memcmp Equal x 1000 "),
  87. m_ulIterations, m_ulRepInlineEQTime);
  88. return S_OK;
  89. }