Source code of Windows XP (NT5)
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.

421 lines
9.6 KiB

  1. // csdrtprf.cxx
  2. #include "csdrt.hxx"
  3. extern BOOL fVerbose;
  4. extern BOOL fMultiStore;
  5. extern IClassAccess *pIClassAccess;
  6. extern IClassAdmin *pIClassAdmin;
  7. extern IClassAdmin *pIClassAdmin2;
  8. extern WCHAR szClassStorePath [_MAX_PATH+1];
  9. extern WCHAR szContainer [_MAX_PATH+1];
  10. extern WCHAR szContainer2 [_MAX_PATH+1];
  11. extern WCHAR szNewContainer [_MAX_PATH+1];
  12. extern UINT cLoops;
  13. extern UINT cCase;
  14. extern GUID TestClsid1, TestClsid2, TestClsid3, TestClsid4, TestClsid5;
  15. extern Sname TestFileExt1, TestFileExt4, TestMimeType2;
  16. extern Sname TestOtherProgID2, TestProgId1, TestProgId3;
  17. HRESULT AddRandomPackage(PACKAGEDETAIL &packagedetail, int i);
  18. void InitTempNames();
  19. /*
  20. RunATest()
  21. {
  22. PACKAGEINFO PackageInfo;
  23. HRESULT hr, hr2;
  24. switch(cCase)
  25. {
  26. //FileExt1
  27. case 1:
  28. hr = LookupByFileext (TestFileExt1, &PackageInfo);
  29. if (SUCCEEDED(hr))
  30. {
  31. // Check expected values
  32. //
  33. AssertPackage1By1(&PackageInfo);
  34. }
  35. break;
  36. //Clsid1
  37. case 2:
  38. hr2 = LookupByClsid (TestClsid1, &PackageInfo);
  39. if (SUCCEEDED(hr2))
  40. {
  41. // Check expected values
  42. //
  43. AssertPackage1By1(&PackageInfo);
  44. }
  45. else
  46. hr = hr2;
  47. break;
  48. //ProgId1
  49. case 3:
  50. hr2 = LookupByProgid (TestProgId1, &PackageInfo);
  51. if (SUCCEEDED(hr2))
  52. {
  53. //
  54. // Check expected values
  55. //
  56. AssertPackage1By1(&PackageInfo);
  57. }
  58. else
  59. hr = hr2;
  60. break;
  61. // MimeType2
  62. case 4:
  63. hr2 = LookupByMimeType (TestMimeType2, &PackageInfo);
  64. if (SUCCEEDED(hr2))
  65. {
  66. //
  67. // Check expected values
  68. //
  69. AssertPackage1By2(&PackageInfo);
  70. }
  71. else
  72. hr = hr2;
  73. break;
  74. //Clsid2
  75. case 5:
  76. hr2 = LookupByClsid (TestClsid2, &PackageInfo);
  77. if (SUCCEEDED(hr2))
  78. {
  79. //
  80. // Check expected values
  81. //
  82. AssertPackage1By2(&PackageInfo);
  83. }
  84. else
  85. hr = hr2;
  86. break;
  87. //ProgId3
  88. case 6:
  89. hr2 = LookupByProgid (TestProgId3, &PackageInfo);
  90. if (SUCCEEDED(hr2))
  91. {
  92. //
  93. // Check expected values
  94. //
  95. AssertPackage2(&PackageInfo);
  96. }
  97. else
  98. hr = hr2;
  99. break;
  100. //TestOtherProgID2
  101. case 7:
  102. hr2 = LookupByProgid (TestOtherProgID2, &PackageInfo);
  103. if (SUCCEEDED(hr2))
  104. {
  105. //
  106. // Check expected values
  107. //
  108. AssertPackage1By1(&PackageInfo);
  109. }
  110. else
  111. hr = hr2;
  112. break;
  113. //FileExt4
  114. case 8:
  115. hr = LookupByFileext (TestFileExt4, &PackageInfo);
  116. if (SUCCEEDED(hr))
  117. {
  118. // Check expected values
  119. //
  120. AssertPackage4(&PackageInfo);
  121. }
  122. break;
  123. // Clsid4
  124. // Should get two packages now !!
  125. case 9:
  126. hr2 = LookupByClsid (TestClsid4, &PackageInfo);
  127. if (SUCCEEDED(hr2))
  128. {
  129. //
  130. // Check expected values
  131. //
  132. AssertPackage4(&PackageInfo);
  133. }
  134. else
  135. hr = hr2;
  136. break;
  137. // Tlbid1
  138. case 10:
  139. hr2 = LookupByTlbid (TestClsid1, &PackageInfo);
  140. if (SUCCEEDED(hr2))
  141. {
  142. //
  143. // Check expected values
  144. //
  145. AssertPackage4(&PackageInfo);
  146. }
  147. else
  148. hr = hr2;
  149. break;
  150. // Tlbid2
  151. case 11:
  152. hr2 = LookupByTlbid (TestClsid2, &PackageInfo);
  153. if (SUCCEEDED(hr2))
  154. {
  155. //
  156. // Check expected values
  157. //
  158. //AssertPackage5(&PackageInfo);
  159. }
  160. else
  161. hr = hr2;
  162. break;
  163. // Clsid5
  164. case 12:
  165. hr2 = LookupByClsid (TestClsid5, &PackageInfo);
  166. if (SUCCEEDED(hr2))
  167. {
  168. //
  169. // Check expected values
  170. //
  171. AssertPackage6(&PackageInfo);
  172. }
  173. else
  174. hr = hr2;
  175. break;
  176. default:
  177. printf("Not yet implemented\n");
  178. break;
  179. }
  180. return hr;
  181. }
  182. void RunPerfTests()
  183. {
  184. DWORD time1, time2, time3, time4;
  185. hr = GetClassAdmin (szContainer, &pIClassAdmin);
  186. if (FAILED(hr))
  187. return;
  188. hr = DoAdminTest(&cCount, &cPkgCount);
  189. if (FAILED(hr))
  190. return;
  191. // Populating class store.
  192. if (!cLoop)
  193. return;
  194. VerbosePrint("Started timing\n");
  195. // take the time time1.
  196. time1 = GetTickCount();
  197. hr = GetClassAccess ();
  198. if (FAILED(hr))
  199. return;
  200. // Get the interface pointers, depending on the test.
  201. RunATest();
  202. // take the time time2.
  203. time2 = GetTickCount();
  204. for (i = 0; i < (cLoops-1); i++)
  205. {
  206. RunATest();
  207. }
  208. // take the time time3
  209. time3 = GetTickCount();
  210. // Release the interface pointers.
  211. // take the time time4
  212. time4 = GetTickCount();
  213. printf("Time1\tTime2\tTime3\tTime4\n");
  214. printf("-----\t-----\t-----\t-----\n\n");
  215. printf("%d\t%d\t%d\t%d\n", time1, time2, time3 time4);
  216. // print the times.
  217. // Parameter based cleanup.
  218. }
  219. */
  220. HRESULT AddRandomUnassignedPackages(int i)
  221. {
  222. PACKAGEDETAIL PackageDetail;
  223. memset(&PackageDetail, 0, sizeof(PACKAGEDETAIL));
  224. PackageDetail.pInstallInfo = (INSTALLINFO *) CoTaskMemAlloc (sizeof(INSTALLINFO));
  225. memset (PackageDetail.pInstallInfo, 0, sizeof(INSTALLINFO));
  226. PackageDetail.pPlatformInfo = (PLATFORMINFO *) CoTaskMemAlloc (sizeof(PLATFORMINFO));
  227. memset (PackageDetail.pPlatformInfo, 0, sizeof(PLATFORMINFO));
  228. PackageDetail.pActInfo = (ACTIVATIONINFO *) CoTaskMemAlloc (sizeof(ACTIVATIONINFO));
  229. memset (PackageDetail.pActInfo, 0, sizeof(ACTIVATIONINFO));
  230. PackageDetail.pInstallInfo->dwActFlags =
  231. ACTFLG_Published + // Published
  232. ACTFLG_UserInstall + // Visible
  233. ACTFLG_OnDemandInstall; // AutoInstall
  234. return AddRandomPackage(PackageDetail, i);
  235. }
  236. HRESULT AddRandomAssignedPackages(int i)
  237. {
  238. PACKAGEDETAIL PackageDetail;
  239. memset(&PackageDetail, 0, sizeof(PACKAGEDETAIL));
  240. PackageDetail.pInstallInfo = (INSTALLINFO *) CoTaskMemAlloc (sizeof(INSTALLINFO));
  241. memset (PackageDetail.pInstallInfo, 0, sizeof(INSTALLINFO));
  242. PackageDetail.pPlatformInfo = (PLATFORMINFO *) CoTaskMemAlloc (sizeof(PLATFORMINFO));
  243. memset (PackageDetail.pPlatformInfo, 0, sizeof(PLATFORMINFO));
  244. PackageDetail.pActInfo = (ACTIVATIONINFO *) CoTaskMemAlloc (sizeof(ACTIVATIONINFO));
  245. memset (PackageDetail.pActInfo, 0, sizeof(ACTIVATIONINFO));
  246. PackageDetail.pInstallInfo->dwActFlags =
  247. ACTFLG_Assigned + // Assigned
  248. ACTFLG_UserInstall + // Visible
  249. ACTFLG_OnDemandInstall; // AutoInstall
  250. return AddRandomPackage(PackageDetail, i);
  251. }
  252. HRESULT DoLogonPerfTest(BOOL fInitialize)
  253. {
  254. UINT i = 0, j = 0;
  255. PACKAGEDISPINFO PackageInfo[30];
  256. IEnumPackage *pIEnumPackage = NULL;
  257. HRESULT hr = S_OK;
  258. DWORD cgot = 0;
  259. DWORD tc1, tc2, tc3, tc4, tc5, tc6, tc;
  260. if (fInitialize)
  261. {
  262. InitTempNames();
  263. // add 500 random packages
  264. for (i = 0; i < 500; i++)
  265. {
  266. hr = AddRandomUnassignedPackages(i);
  267. if (FAILED(hr))
  268. return hr;
  269. }
  270. VerbosePrint("Added 500 unassigned apps\n");
  271. // add 5 known packages that are assigned.
  272. for (i = 0; i < 5; i++)
  273. {
  274. hr = AddRandomAssignedPackages(i+500);
  275. if (FAILED(hr))
  276. return hr;
  277. }
  278. VerbosePrint("Added 5 Assigned Apps\n");
  279. pIClassAdmin->Release();
  280. }
  281. // Lookup for assigned packages using
  282. // CoEnumAppInfo
  283. tc = GetTickCount();
  284. cLoops = 1;
  285. for (i = 0; i < (int)cLoops; i++)
  286. {
  287. tc1 = GetTickCount();
  288. hr = CsEnumApps(
  289. NULL,
  290. NULL,
  291. NULL,
  292. APPINFO_ASSIGNED | APPINFO_MSI,
  293. &pIEnumPackage
  294. );
  295. tc2 = GetTickCount();
  296. printf("CsEnumApps: Time=%d MilliSec\n", tc2 - tc1);
  297. if (FAILED(hr)) {
  298. printf("CsEnumApps returned hr = 0x%x\n", hr);
  299. return hr;
  300. }
  301. /*
  302. for (j = 0; j < 5; j++)
  303. {
  304. tc3 = GetTickCount();
  305. hr = pIEnumPackage->Next(1, PackageInfo, &cgot);
  306. if (hr != S_OK) {
  307. printf("Next %d returned hr = 0x%x\n", j+1, hr);
  308. return hr;
  309. }
  310. tc4 = GetTickCount();
  311. printf("Next %d\n", tc4 - tc3);
  312. }
  313. */
  314. hr = pIEnumPackage->Next(20, PackageInfo, &cgot);
  315. tc5 = GetTickCount();
  316. // printf("Last Next %d\n", tc5 - tc4);
  317. printf("Browsing: Time = %d MilliSec, # of assigned apps = %d\n",
  318. tc5 - tc2, cgot);
  319. if (fVerbose)
  320. for (j = 0; j < cgot; j++)
  321. {
  322. PrintPackageInfo(&PackageInfo[j]);
  323. }
  324. printf("Next(%d) returned hr = 0x%x\n", 20, hr);
  325. // if (i%10 == 0)
  326. // VerbosePrint(".");
  327. // if (i % 100 == 0)
  328. // VerbosePrint("\n");
  329. pIEnumPackage->Release();
  330. tc6 = GetTickCount();
  331. printf("Release %d\n", tc6 - tc5);
  332. }
  333. printf ("End of Class Store Stress for %d passes (%d MilliSec Per Loop).\n",
  334. cLoops,
  335. (GetTickCount() - tc)/cLoops);
  336. return S_OK;
  337. // measure the time taken.
  338. }