// // perfct.cpp // #include "private.h" #include "perfct.h" #ifdef DEBUG extern DBG_MEMSTATS s_Dbg_MemStats; DBG_MEM_COUNTER g_rgPerfObjCounters[] = { { TEXT("CAnchorRef: "), 0 }, { TEXT("CRange: "), 0 }, { TEXT("CLoaderACP: "), 0 }, { TEXT("CACPWrap: "), 0 }, { TEXT("CAnchorList: "), 0 }, { TEXT("CAnchor: "), 0 }, { TEXT("CEnumAppPropRanges: "), 0 }, { TEXT("CAppProperty: "), 0 }, { TEXT("CEnumUberRanges: "), 0 }, { TEXT("CUberProperty: "), 0 }, { TEXT("CEnumProperties: "), 0 }, { TEXT("CProperty: "), 0 }, { TEXT("CCategoryMgr: "), 0 }, { TEXT("CEnumCategories: "), 0 }, { TEXT("CCompartmentMgr: "), 0 }, { TEXT("CEnumCompartment: "), 0 }, { TEXT("CCompartment: "), 0 }, { TEXT("CGlobalCompartment: "), 0 }, { TEXT("CCompartmentSub: "), 0 }, { TEXT("CEditRecord: "), 0 }, { TEXT("CEnumPropertyRanges: "), 0 }, { TEXT("CInputContext: "), 0 }, { TEXT("CSpanSet: "), 0 }, { TEXT("PROPERTYLIST: "), 0 }, { TEXT("---------------------"), 0 }, { TEXT("CACPWrap::GetText "), 0 }, { TEXT("CACPWrap:GetText:loop"), 0 }, { TEXT("ShiftRegion:GetText "), 0 }, { TEXT("GetTextComp:GetText "), 0 }, { TEXT("PlainTextOff:GetText "), 0 }, { TEXT("ATOF GetText calls: "), 0 }, { TEXT("ShiftCond:GetText "), 0 }, { TEXT("---------------------"), 0 }, { TEXT("ATOF calls: "), 0 }, { TEXT("ATON calls: "), 0 }, { TEXT("Normalize calls: "), 0 }, { TEXT("ShiftRegion calls: "), 0 }, { TEXT("Renormalize calls: "), 0 }, { TEXT("---------------------"), 0 }, { TEXT("CreateRangeACP "), 0 }, { TEXT("Lazy:Norm "), 0 }, { TEXT("---------------------"), 0 }, { TEXT("ITfRange::ShiftStart "), 0 }, { TEXT("ITfRange::ShiftEnd "), 0 }, { TEXT("ITfRange::GetText "), 0 }, { TEXT("ITfRange::SetText "), 0 }, { TEXT("CAnchorRef::Shift "), 0 }, { TEXT("key down events "), 0 }, }; #endif // DEBUG #ifdef PERF_DUMP LARGE_INTEGER g_liPerfFreq = { 0 }; ULONG g_cStrokes = 0; struct { LARGE_INTEGER liStart[PERF_STROKE_ARRAYSIZE]; LARGE_INTEGER liEnd[PERF_STROKE_ARRAYSIZE]; } g_rgPerfStrokes[2048] = { 0 }; BOOL Perf_Init() { QueryPerformanceFrequency(&g_liPerfFreq); return TRUE; } //+--------------------------------------------------------------------------- // // Perf_GetTicks // //---------------------------------------------------------------------------- LARGE_INTEGER GetTicks() { LARGE_INTEGER li; if (g_liPerfFreq.QuadPart != 0) { QueryPerformanceCounter(&li); } else { li.LowPart = GetTickCount(); li.HighPart = 0; } return li; } //+--------------------------------------------------------------------------- // // Perf_GetTickDifference // //---------------------------------------------------------------------------- ULONG GetTickDifference(LARGE_INTEGER liStartTicks, LARGE_INTEGER liEndTicks) { liEndTicks.QuadPart -= liStartTicks.QuadPart; if (g_liPerfFreq.QuadPart != 0) { liEndTicks.QuadPart /= (g_liPerfFreq.QuadPart / 1000); } return liEndTicks.LowPart; } //+--------------------------------------------------------------------------- // // Perf_StartStroke // //---------------------------------------------------------------------------- void Perf_StartStroke(UINT iIndex) { LARGE_INTEGER liPrevTotal; if (g_cStrokes < ARRAYSIZE(g_rgPerfStrokes)) { liPrevTotal.QuadPart = g_rgPerfStrokes[g_cStrokes].liEnd[iIndex].QuadPart - g_rgPerfStrokes[g_cStrokes].liStart[iIndex].QuadPart; g_rgPerfStrokes[g_cStrokes].liStart[iIndex].QuadPart = GetTicks().QuadPart - liPrevTotal.QuadPart; } } //+--------------------------------------------------------------------------- // // Perf_EndStroke // //---------------------------------------------------------------------------- void Perf_EndStroke(UINT iIndex) { if (g_cStrokes < ARRAYSIZE(g_rgPerfStrokes)) { g_rgPerfStrokes[g_cStrokes].liEnd[iIndex] = GetTicks(); } if (iIndex == PERF_STROKE_DOWN) { g_cStrokes++; } } #include //+--------------------------------------------------------------------------- // // Perf_DumpStats // //---------------------------------------------------------------------------- void Perf_DumpStats() { // // add the application name to check the cicero's performance. // static const TCHAR *c_rgPerfProcesses[] = { TEXT("notepad.exe"), }; FILE *file; TCHAR ach[MAX_PATH]; DWORD cch; DWORD cchTest; LONG i; // // only dump perf info for certain processes // for (i=0; i