//+- ----------------------------------------------------------------------- // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1993. // // File: bm_activ.cxx // // Contents: Ole object activation test // // Classes: COleActivationTest // // History: 1-July-93 t-martig Created // //-------------------------------------------------------------------------- #include #pragma hdrstop #include #include TCHAR *COleActivationTest::Name () { return TEXT("ObjActivation"); } SCODE COleActivationTest::Setup (CTestInput *pInput) { SCODE sc; CTestBase::Setup(pInput); // get iteration count m_ulIterations = pInput->GetIterations(Name()); // initialize state for (ULONG iCtx=0; iCtxGetGUID(&m_ClsID[iCtx], Name(), apszClsIDName[iCtx]); if (FAILED(sc)) { Log (TEXT("Setup - GetClassID failed."), sc); return sc; } INIT_RESULTS(m_ulGetClassObjectTime[iCtx]); INIT_RESULTS(m_ulCreateInstanceTime[iCtx]); INIT_RESULTS(m_ulLoadTime[iCtx]); INIT_RESULTS(m_ulPunkReleaseTime[iCtx]); INIT_RESULTS(m_ulCFReleaseTime[iCtx]); } sc = InitCOM(); if (FAILED(sc)) { Log (TEXT("Setup - InitCOM failed."), sc); return sc; } return S_OK; } SCODE COleActivationTest::Cleanup () { UninitCOM(); return S_OK; } SCODE COleActivationTest::Run () { CStopWatch sw; IPersistFile *pIPF = NULL; IClassFactory *pICF = NULL; for (ULONG iCtx=0; iCtxCreateInstance(NULL, IID_IPersistFile, (void **)&pIPF); m_ulCreateInstanceTime[iCtx][iIter] = sw.Read (); Log (TEXT("CreateInstance"), sc); sw.Reset(); pICF->Release(); m_ulCFReleaseTime[iCtx][iIter] = sw.Read(); if (SUCCEEDED(sc)) { // load the data sw.Reset(); pIPF->Load(apszPerstName[iCtx], 0); m_ulLoadTime[iCtx][iIter] = sw.Read(); sw.Reset(); pIPF->Release (); m_ulPunkReleaseTime[iCtx][iIter] = sw.Read(); } else { m_ulCreateInstanceTime[iCtx][iIter] = NOTAVAIL; } } else { m_ulGetClassObjectTime[iCtx][iIter] = NOTAVAIL; } } } return S_OK; } SCODE COleActivationTest::Report (CTestOutput &output) { output.WriteSectionHeader (Name(), TEXT("CoGetClassObject"), *m_pInput); for (ULONG iCtx=0; iCtxRelease "), m_ulIterations, m_ulCFReleaseTime[iCtx]); output.WriteResults (TEXT("pIPF->Load "), m_ulIterations, m_ulLoadTime[iCtx]); output.WriteResults (TEXT("pIPF->Release "), m_ulIterations, m_ulPunkReleaseTime[iCtx]); } return S_OK; }