// writeJCLFile // // Construct JCL Load records and write into the JCL file // static int writeJCLFile(methodInfo* pMethodInfo, const void* pCodeAddr, gtUInt32 codeSize, std::wstring* pJncFileName) { gtUInt64 loadTimeStamp = 0; if ((NULL == pCodeAddr) || (NULL == pMethodInfo)) { return AMDT_JITPROFILE_ERROR_INVALIDARG; } if ((NULL == gJCLWriter)) { return AMDT_JITPROFILE_FAILED; } JitLoadRecord jclLoadRecord; // Get the module load timestamp queryCurrentTime(loadTimeStamp); jclLoadRecord.loadTimestamp = loadTimeStamp; jclLoadRecord.blockStartAddr = (gtUInt64)pCodeAddr; jclLoadRecord.blockEndAddr = (gtUInt64)pCodeAddr + codeSize; jclLoadRecord.threadID = 0; // Construct method signature as ClassName::MethodName if (NULL != pMethodInfo->pClassName) { wcsncpy_truncate(jclLoadRecord.classFunctionName, (OS_MAX_PATH - 3), pMethodInfo->pClassName); wcsncat_truncate(jclLoadRecord.classFunctionName, OS_MAX_PATH, L"::"); } if (NULL != pMethodInfo->pMethodName) { wcsncat_truncate(jclLoadRecord.classFunctionName, OS_MAX_PATH, pMethodInfo->pMethodName); } if (NULL != pMethodInfo->pSrcFileName) { wcsncpy_truncate(jclLoadRecord.srcFileName, OS_MAX_PATH, pMethodInfo->pSrcFileName); } wcsncpy_truncate(jclLoadRecord.jncFileName, OS_MAX_PATH, pJncFileName->c_str()); // write the JITLoadRecord for this module gJCLWriter->WriteLoadRecord(&jclLoadRecord); return AMDT_JITPROFILE_SUCCESS; } // writeJCLFile
// AMDTJitProfileMethodUnload // // API to be called when a method is unloaded // int AMDTJitProfileMethodUnload(AMDTJitMethodUnload* pMethodInfo) { if (false == gAMDTJitProfileEnabled) { return AMDT_JITPROFILE_ERROR_DISABLED; } if (NULL == pMethodInfo) { return AMDT_JITPROFILE_ERROR_INVALIDARG; } if (NULL == gJCLWriter) { return AMDT_JITPROFILE_FAILED; } gtUInt64 codeAddr = (gtUInt64)pMethodInfo->pCodeAddr; // TDB: should we use "UnknownClassName" if the AMDTJitMethodInfo::pClassName is NULL // wchar_t* pClassSig = (NULL != pMethodInfo->pClassName) // ? pMethodInfo->pClassName : (wchar_t*)gUnknownClassName; wchar_t* pClassSig = pMethodInfo->pClassName; wchar_t* pMethodName = (NULL != pMethodInfo->pMethodName) ? pMethodInfo->pMethodName : (wchar_t*)gUnknownMethodName; if (gJitVerbose) { wprintf(L"AMDTJitProfileMethodUnload: 0x%lx: %s:%s\n", (unsigned long) codeAddr, pClassSig, pMethodName); } JitUnloadRecord jclUnloadRec; gtUInt64 unloadTimeStamp = 0; queryCurrentTime(unloadTimeStamp); jclUnloadRec.unloadTimestamp = unloadTimeStamp; jclUnloadRec.blockStartAddr = codeAddr; gJCLWriter->WriteUnloadRecord(&jclUnloadRec); return AMDT_JITPROFILE_SUCCESS; } // AMDTJitProfileMethodUnload
/**@brief Funkcja oblicza interwa³ czasowy jaki up³yn¹³ od ostatniej ramki. Poza tym s¹ tu generowane eventy dotycz¹ce czasu, opóŸnieñ itp. @return Zwraca interwa³ jaki up³yn¹³ od ostatniego wywo³ania funkcji.*/ float TimeManager::onStartRenderFrame() { int64 timeCurrent = queryCurrentTime(); int64 timeDiff; timeDiff = timeCurrent - time_previous; float timeInterval = (float)timeDiff / timer_frequency; lag += timeInterval; //todo: generujemy eventy czasowe //zapisujemy obecny czas i wychodzimy z funkcji time_previous = timeCurrent; ++frames; //inkrementujemy licznik klatek return timeInterval; }
/**@brief Zwraca czas w sekundach od w³¹czenia silnika. */ double TimeManager::queryTimeFromBegin() { int64 currentTime = queryCurrentTime(); int64 timeDiff = currentTime - begin_time; return (double)timeDiff / timer_frequency; }