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.

201 lines
4.5 KiB

  1. //+------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993.
  5. //
  6. // File: bm_init.cxx
  7. //
  8. // Contents: OleInitialize/OleUninitialize tests
  9. //
  10. // Classes: COleInitializeTest
  11. //
  12. // History: 1-July-93 t-martig Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #include <headers.cxx>
  16. #pragma hdrstop
  17. #include <bm_init.hxx>
  18. #include <oletest.hxx>
  19. DWORD dwInitFlag = 0;
  20. TCHAR *COleInitializeTest::Name ()
  21. {
  22. return TEXT("OleInitialize");
  23. }
  24. SCODE COleInitializeTest::Setup (CTestInput *pInput)
  25. {
  26. CTestBase::Setup(pInput);
  27. // get iteration count
  28. m_ulIterations = pInput->GetIterations(Name());
  29. // initialize state
  30. INIT_RESULTS(m_ulOleInitializeTime);
  31. INIT_RESULTS(m_ulOleUninitializeTime);
  32. INIT_RESULTS(m_ulRepOleInitializeTime);
  33. INIT_RESULTS(m_ulRepOleUninitializeTime);
  34. INIT_RESULTS(m_ulCoInitializeTime);
  35. INIT_RESULTS(m_ulCoUninitializeTime);
  36. INIT_RESULTS(m_ulRepCoInitializeTime);
  37. INIT_RESULTS(m_ulRepCoUninitializeTime);
  38. return S_OK;
  39. }
  40. SCODE COleInitializeTest::Cleanup ()
  41. {
  42. return S_OK;
  43. }
  44. SCODE COleInitializeTest::Run ()
  45. {
  46. CStopWatch sw;
  47. SCODE sc;
  48. // compute times for OleInit, OleUninit.
  49. for (ULONG iIter=0; iIter<m_ulIterations; iIter++)
  50. {
  51. sw.Reset();
  52. #ifdef OLE_THREADING_SUPPORT
  53. sc = OleInitializeEx(NULL, dwInitFlag);
  54. #else
  55. sc = OleInitialize(NULL);
  56. #endif
  57. m_ulOleInitializeTime[iIter] = sw.Read();
  58. Log (TEXT("OleInitialize"), sc);
  59. if (SUCCEEDED(sc))
  60. {
  61. sw.Reset();
  62. OleUninitialize();
  63. m_ulOleUninitializeTime[iIter] = sw.Read();
  64. Log (TEXT("OleUninitialize"), sc);
  65. }
  66. else
  67. {
  68. m_ulOleInitializeTime[iIter] = NOTAVAIL;
  69. }
  70. sw.Reset();
  71. #ifdef COM_THREADING_SUPPORT
  72. sc = CoInitializeEx(NULL, dwInitFlag);
  73. #else
  74. sc = CoInitialize(NULL);
  75. #endif
  76. m_ulCoInitializeTime[iIter] = sw.Read();
  77. Log (TEXT("CoInitialize"), sc);
  78. if (SUCCEEDED(sc))
  79. {
  80. sw.Reset();
  81. CoUninitialize();
  82. m_ulCoUninitializeTime[iIter] = sw.Read();
  83. Log (TEXT("CoUninitialize"), sc);
  84. }
  85. else
  86. {
  87. m_ulCoInitializeTime[iIter] = NOTAVAIL;
  88. }
  89. }
  90. // first, compute times for repetitive OleInit
  91. for (iIter=0; iIter<m_ulIterations; iIter++)
  92. {
  93. sw.Reset();
  94. #ifdef OLE_THREADING_SUPPORT
  95. sc = OleInitializeEx(NULL, dwInitFlag);
  96. #else
  97. sc = OleInitialize(NULL);
  98. #endif
  99. m_ulRepOleInitializeTime[iIter] = sw.Read();
  100. Log (TEXT("OleInitialize"), sc);
  101. if (FAILED(sc))
  102. {
  103. m_ulRepOleInitializeTime[iIter] = NOTAVAIL;
  104. }
  105. }
  106. // second, compute times for repetitive OleUninit
  107. for (iIter=0; iIter<m_ulIterations; iIter++)
  108. {
  109. sw.Reset();
  110. OleUninitialize();
  111. m_ulRepOleUninitializeTime[iIter] = sw.Read();
  112. Log (TEXT("OleUninitialize"), sc);
  113. }
  114. // first, compute times for repetitive CoInit
  115. for (iIter=0; iIter<m_ulIterations; iIter++)
  116. {
  117. sw.Reset();
  118. #ifdef COM_THREADING_SUPPORT
  119. sc = CoInitializeEx(NULL, dwInitFlag);
  120. #else
  121. sc = CoInitialize(NULL);
  122. #endif
  123. m_ulRepCoInitializeTime[iIter] = sw.Read();
  124. Log (TEXT("CoInitialize"), sc);
  125. if (FAILED(sc))
  126. {
  127. m_ulRepCoInitializeTime[iIter] = NOTAVAIL;
  128. }
  129. }
  130. // second, compute times for repetitive CoUninit
  131. for (iIter=0; iIter<m_ulIterations; iIter++)
  132. {
  133. sw.Reset();
  134. CoUninitialize();
  135. m_ulRepCoUninitializeTime[iIter] = sw.Read();
  136. Log (TEXT("CoUninitialize"), sc);
  137. }
  138. return S_OK;
  139. }
  140. SCODE COleInitializeTest::Report (CTestOutput &output)
  141. {
  142. output.WriteSectionHeader (Name(), TEXT("OleInitialize / OleUninitialize"), *m_pInput);
  143. output.WriteResults (TEXT("\nOleInitialize "), m_ulIterations,
  144. m_ulOleInitializeTime);
  145. output.WriteResults (TEXT("OleUninitialize "), m_ulIterations,
  146. m_ulOleUninitializeTime);
  147. output.WriteResults (TEXT("\nRepOleInitialize "), m_ulIterations,
  148. m_ulRepOleInitializeTime);
  149. output.WriteResults (TEXT("RepOleUninitialize"), m_ulIterations,
  150. m_ulRepOleUninitializeTime);
  151. output.WriteResults (TEXT("\nCoInitialize "), m_ulIterations,
  152. m_ulCoInitializeTime);
  153. output.WriteResults (TEXT("CoUninitialize "), m_ulIterations,
  154. m_ulCoUninitializeTime);
  155. output.WriteResults (TEXT("\nRepCoInitialize "), m_ulIterations,
  156. m_ulRepCoInitializeTime);
  157. output.WriteResults (TEXT("RepCoUninitialize"), m_ulIterations,
  158. m_ulRepCoUninitializeTime);
  159. return S_OK;
  160. }