///////////////////////////////////////////////////////////////////////////// // module MesaMicrocodeOps static functions static void CollectStats(CString & message) { // collect total time u32 pulseCount = 0; LARGE_INTEGER count; if ((0 != s_nPulseFrequencyInCountsPerSecond) && ::QueryPerformanceCounter(&count)) { u64 currentPulseCount = (u64)(count.QuadPart) - s_nPulseBase; currentPulseCount *= 1000000; currentPulseCount /= s_nPulseFrequencyInCountsPerSecond; pulseCount = (u32)currentPulseCount; } u32 milliseconds = pulseCount / 1000; u32 seconds = milliseconds / 1000; u32 minutes = seconds / 60; u32 minsec = seconds % 60; milliseconds = milliseconds % 1000; u32 numInstructions = MesaProcessor::GetNumExecutedInstructions(); message.Format("Mesa Processor Finished. " "Total Runtime = %s microseconds, " "%s.%03d seconds, " "%d:%d.%03d minutes. " "Instructions Dispatched = %s. ", GetCommaString(pulseCount), GetCommaString(seconds), milliseconds, minutes, minsec, milliseconds, GetCommaString(numInstructions)); // compute the microseconds per instruction or instructions per microsecond CString additional; if (pulseCount > numInstructions) { // microseconds per instruction u64 microseconds = ((u64)pulseCount * 100) / numInstructions; u32 msi1 = (u32)(microseconds / 100); u32 msi2 = (u32)(microseconds % 100); additional.Format("%s.%02d microseconds per instruction.", GetCommaString(msi1), msi2); } else { // instructions per microsecond u64 instructions = ((u64)numInstructions * 100) / pulseCount; u32 ims1 = (u32)(instructions / 100); u32 ims2 = (u32)(instructions % 100); additional.Format("%s.%02d instructions per microsecond.", GetCommaString(ims1), ims2); } message += additional; }
std::string IObject::GetValue(int index) { MyStructMeta ** meta = this->GetMetaData(); if(index < 0 || index >= HeaderCount()) { return ""; } MyStructMeta * ameta = meta[index]; if(ameta->eType == type_is_bstr_t) { return ( (LPCSTR) *(bstr_t *) ((char *) this + ameta->oFieldOffset) ); } // treat like a vector of bstr for now name=value(units)description,... // Big problem is multiline descriptions - not handled else if(ameta->eType == type_is_propertylist) { std::vector<bstr_t> * bstrs = (std::vector<bstr_t> *) ((char *) this + ameta->oFieldOffset); bstr_t a = accumulate( (*bstrs).begin(), (*bstrs).end(), bstr_t("") ); return ((LPCSTR) a); } else if(ameta->eType == type_is_array) // comma delimited string { std::vector<bstr_t> * bstrs = (std::vector<bstr_t> *) ((char *) this + ameta->oFieldOffset); bstr_t a = GetCommaString(bstrs,","); // accumulate( (*bstrs).begin(), (*bstrs).end(), bstr_t(",") ); return ((LPCSTR) a); } return ""; }