void CProfiling::ShowCPU_Usage() {
    int64_t TotalTime, CPU = 0, Alist = 0, Dlist = 0, Idle = 0;
    PROFILE_ENRTY Entry;

    if (m_CurrentDisplayCount > 0) { m_CurrentDisplayCount -= 1; return; }
    m_CurrentDisplayCount = MAX_FRAMES;

    Entry = m_Entries.find(Timer_R4300);
    if (Entry != m_Entries.end()) { CPU = Entry->second; }

    Entry = m_Entries.find(Timer_RefreshScreen);
    if (Entry != m_Entries.end()) { CPU += Entry->second; }

    Entry = m_Entries.find(Timer_RSP_Dlist);
    if (Entry != m_Entries.end()) { Dlist = Entry->second; }

    Entry = m_Entries.find(Timer_UpdateScreen);
    if (Entry != m_Entries.end()) { Dlist += Entry->second; }

    Entry = m_Entries.find(Timer_RSP_Alist);
    if (Entry != m_Entries.end()) { Alist = Entry->second; }

    Entry = m_Entries.find(Timer_Idel);
    if (Entry != m_Entries.end()) { Idle = Entry->second; }

    TotalTime = CPU + Alist + Dlist + Idle;

    g_Notify->DisplayMessage(0, stdstr_f("r4300i: %0.1f%c    GFX: %0.1f%c    Alist: %0.1f%c    Idle: %0.1f%c",
        (float)(((double)CPU / (double)TotalTime) * 100), '%',
        (float)(((double)Dlist / (double)TotalTime) * 100), '%',
        (float)(((double)Alist / (double)TotalTime) * 100), '%',
        (float)(((double)Idle / (double)TotalTime) * 100), '%').c_str());

    ResetCounters();
}
Example #2
0
// --------------------------------------------------------------------------
//
// Function
//		Name:    SocketStreamTLS::Open(const TLSContext &, int, const char *, int)
//		Purpose: Open connection, and perform TLS handshake
//		Created: 2003/08/06
//
// --------------------------------------------------------------------------
void SocketStreamTLS::Open(const TLSContext &rContext, Socket::Type Type,
	const std::string& rName, int Port)
{
	SocketStream::Open(Type, rName, Port);
	Handshake(rContext);
	ResetCounters();
}
Example #3
0
void Camera::Init(double distance)
{
	_distance = distance;
	_idealDistance = _distance;
	_transform.position = vec3(0.0f, 0.0f, distance);
	_origin = vec3(0.0f, 0.0f, 0.0f);
	_dummy.Init(vec3(0.0f, 10.0f, 0.0f));
	//_target = _dummy.GetPositionPointer();
	_previousTargetPosition = _dummy.GetPosition();
	_upVector = vec3(0, 1, 0);

	_heightSpeed = 10.0;
	_zoomSpeed = 10.0;
	_rotationSpeedX = 0.05f;
	_rotationSpeedY = 0.1f;

	_angle = 0.0;

	_isRotating = false;

	_inputManager = InputManager::GetInstance();

	ResetCounters();
	_leftRight = 1;
	
	_isAnimating = false;
	_isFollowing = true;
}
Example #4
0
designview::designview(BRect rect, char *name, uint32 resizingMode, uint32 flags)
			: BView(rect, name, resizingMode,flags)
{
	//settings
	IsDragging = false;
	ShowGrid = true;
	ShowHandles = true;
	scale = 10;
	currenttype="BUTTON";
	
	//reset
	ResetCounters();
}
STATUS SSDPerformanceReporter::Initialize(
	DdmReporter		*pPHSReporter,	// Pointer to PHSReporter DDM.
	DID				didDdm,
	VDN				vdnDdm,
	REPORTERCODE	ReporterCode
)
{
STATUS	status;

	//
	// Initialize our parent Ddm.  Need to do this to send etc.
	SetParentDdm(m_pPHSReporter = pPHSReporter);

	// Initialize the DataBlock structure with Storage Roll Call data before handing off
	strcpy(m_Data.SRCandExportTableName, STORAGE_ROLL_CALL_TABLE);
	
	m_Data.pSRCandExportRecord = &m_SRCRecord;
	m_Data.cbSRCandExportRecordMax = sizeof(m_SRCRecord);
	
	strcpy(m_Data.SRCandExportvdnName, fdSRC_VDNBSADDM); // Actual name of vdnDdm field in SRC/Export/Loop Descriptor table
	
	strcpy(m_Data.SRCandExportPHSRowIDName, fdSRC_PERFORMANCE_RID);	// String64 rgbFieldName

	m_Data.pSRCandExportRowID = &m_SRCRecord.rid;
	m_Data.pPHSRowID = &m_SRCRecord.ridPerformanceRecord;

	// Also init PHS record for Array Performance record
	strcpy(m_Data.PHSTableName, SSD_PERFORMANCE_TABLE); 	// Name of table to send PHS data to
	m_Data.aPHSTableFieldDefs = (fieldDef *)aSSDPerformanceTable_FieldDefs;	// FieldDefs for PHS table 
	m_Data.cbPHSTableFieldDefs = cbSSDPerformanceTable_FieldDefs;	// size of PHS table fieldDefs, U32 cbrgFieldDefs

	m_Data.pPHSRecord = &m_SSDPerformanceRecord;			// A pointer to a buffer for a PHS row record
	m_Data.cbPHSRecord = sizeof(m_SSDPerformanceRecord); 	// Size of a PHS row record, cbRowData
	m_Data.cbPHSRecordMax = sizeof(m_SSDPerformanceRecord); // Maximum size of buffer to receive row data, cbRowDataRetMax

	m_Data.pRefreshRate = &m_SSDPerformanceRecord.RefreshRate;
	m_Data.pSampleRate = &m_SSDPerformanceRecord.SampleRate;

	ResetCounters();	// Not really needed as the base object should call ResetCounters before
						// starting the data collection.

	// Up up and away...
	status = InitSRCandExport(&m_Data, didDdm, vdnDdm, ReporterCode);
	return status;
 }
Example #6
0
// --------------------------------------------------------------------------
//
// Function
//		Name:    SocketStreamTLS::SocketStreamTLS()
//		Purpose: Constructor
//		Created: 2003/08/06
//
// --------------------------------------------------------------------------
SocketStreamTLS::SocketStreamTLS()
	: mpSSL(0), mpBIO(0)
{
	ResetCounters();
}
Example #7
0
void CProfiling::GenerateLog()
{
    stdstr LogFileName;
    {
        CLog Log;
        Log.Open("Profiling.txt");
        LogFileName = Log.FileName();

        //Get the total time
        int64_t TotalTime = 0;
        for (PROFILE_ENRTY itemTime = m_Entries.begin(); itemTime != m_Entries.end(); itemTime++)
        {
            TotalTime += itemTime->second;
        }

        //Create a sortable list of items
        std::vector<PROFILE_VALUE *> ItemList;
        for (PROFILE_ENRTY Entry = m_Entries.begin(); Entry != m_Entries.end(); Entry++)
        {
            ItemList.push_back(&(*Entry));
        }

        //sort the list with a basic bubble sort
        for (size_t OuterPass = 0; OuterPass < (ItemList.size() - 1); OuterPass++)
        {
            for (size_t InnerPass = 0; InnerPass < (ItemList.size() - 1); InnerPass++)
            {
                if (ItemList[InnerPass]->second < ItemList[InnerPass + 1]->second)
                {
                    PROFILE_VALUE * TempPtr = ItemList[InnerPass];
                    ItemList[InnerPass] = ItemList[InnerPass + 1];
                    ItemList[InnerPass + 1] = TempPtr;
                }
            }
        }

        TIMER_NAME TimerNames[] =
        {
            { Timer_R4300, "R4300" },
            { Timer_RSP_Dlist, "RSP: Dlist" },
            { Timer_RSP_Alist, "RSP: Alist" },
            { Timer_RSP_Unknown, "RSP: Unknown" },
            { Timer_RefreshScreen, "Refresh Screen" },
            { Timer_UpdateScreen, "Update Screen" },
            { Timer_UpdateFPS, "Update FPS" },
            { Timer_FuncLookup, "Function Lookup" },
            { Timer_Done, "Timer_Done" },
            { Timer_GetBlockInfo, "Timer_GetBlockInfo" },
            { Timer_AnalyseBlock, "Timer_AnalyseBlock" },
            { Timer_CompileBlock, "Timer_CompileBlock" },
            { Timer_CompileDone, "Timer_CompileDone" },
        };

        for (size_t count = 0; count < ItemList.size(); count++)
        {
            char Buffer[255];
            double CpuUsage = ((double)ItemList[count]->second / (double)TotalTime) * 100;
            if (CpuUsage <= 0.2) { continue; }
            sprintf(Buffer, "Func 0x%08X", ItemList[count]->first);
            for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++)
            {
                if (ItemList[count]->first == TimerNames[NameID].Timer)
                {
                    strcpy(Buffer, TimerNames[NameID].Name);
                    break;
                }
            }
            Log.LogF("%s\t%2.2f", Buffer, CpuUsage);
        }
    }

    ResetCounters();
}
Example #8
0
	//Generate a log file with the current results, this will also reset the counters
	void GenerateLog   ( void )
	{
		stdstr LogFileName;
		{
			CLog Log;
			Log.Open("RSP Profiling.txt");
			LogFileName = Log.FileName();

			//Get the total time
			__int64 TotalTime = 0;
			for (PROFILE_ENRTY itemTime = m_Entries.begin(); itemTime != m_Entries.end(); itemTime++ )
			{
				TotalTime += itemTime->second;
			}

			//Create a sortable list of items
			std::vector<PROFILE_VALUE *> ItemList;
			for (PROFILE_ENRTY Entry = m_Entries.begin(); Entry != m_Entries.end(); Entry++ )
			{
				ItemList.push_back(&(*Entry));
			}

			//sort the list with a basic bubble sort
			if (ItemList.size() > 0)
			{
				for (size_t OuterPass = 0; OuterPass < (ItemList.size() - 1); OuterPass++ )
				{
					for (size_t InnerPass = 0; InnerPass < (ItemList.size() - 1); InnerPass++ )
					{
						if (ItemList[InnerPass]->second < ItemList[InnerPass + 1]->second)
						{
							PROFILE_VALUE * TempPtr = ItemList[InnerPass];
							ItemList[InnerPass] = ItemList[InnerPass + 1];
							ItemList[InnerPass + 1] = TempPtr;
						}
					}
				}
			}

			TIMER_NAME TimerNames[] = {
				{Timer_Compiling,     "RSP: Compiling"},
				{Timer_RSP_Running,   "RSP: Running"},
				{Timer_R4300_Running, "R4300: Running"},
				{Timer_RDP_Running,   "RDP: Running"},
			};

			for (size_t count = 0; count < ItemList.size(); count++ )
			{
				char Buffer[255];
				float CpuUsage = (float)(((double)ItemList[count]->second / (double)TotalTime) * 100);

				if (CpuUsage <= 0.2) { continue; }
				sprintf(Buffer, "Func 0x%08X", ItemList[count]->first);
				for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++)
				{
					if (ItemList[count]->first == (DWORD)TimerNames[NameID].Timer)
					{
						strcpy(Buffer,TimerNames[NameID].Name);
						break;
					}
				}
				Log.LogF("%s\t%2.2f",Buffer,  CpuUsage);
			}
		}

		ShellExecute(NULL,"open",LogFileName.c_str(),NULL,NULL,SW_SHOW);
		ResetCounters();
	}
Example #9
0
int main(int argc, char* const argv[])
{
	int i;
	char szSimFindIni[MAX_PATH];
	char szTable[MAX_PATH];
	char szOutFile[MAX_PATH];
	char szStatFile[MAX_PATH];
	char szMatchFile[MAX_PATH];
	
#ifdef __APPLE__
	g_bMac = true;
#endif

	// Read specs for run out of INI file
	if (argc > 1)
		strcpy(szSimFindIni, argv[1]);
	else if (g_bMac)
		sprintf(szSimFindIni, "/Users/ipye/Desktop/cmps221/1_hashproj/sub/simhash/MacFind.ini");
	else
		sprintf(szSimFindIni, "WinFind.ini");


	FILE* fp = fopen(szSimFindIni, "rt");
	if (fp == NULL)
	{
		printf("main: failed to load %s\n", szSimFindIni);
		return 1;
	}

	if ((fscanf(fp, "Table=%s\n", szTable) != 1) ||
		(fscanf(fp, "Keys=%d\n", &g_nKeys) != 1) ||
		(fscanf(fp, "OutFile=%s\n", szOutFile) != 1) ||
		(fscanf(fp, "StatFile=%s\n", szStatFile) != 1) ||
		(fscanf(fp, "MatchFile=%s\n", szMatchFile) != 1) ||
		(fscanf(fp, "Tolerance=%f\n", &g_fSumToler) != 1) )
	{
		printf("main: Invalid INI file '%s'\n", szSimFindIni);
		return 1;
	}
	fclose(fp);
	COL_TAG1 = COL_KEY1 + g_nKeys;
	g_pnKeyHits = (int*) calloc(g_nKeys, sizeof(int));
	g_pnCollisions = (int*) calloc(g_nKeys, sizeof(int));
	g_pnSumHits = (int*) calloc(g_nKeys, sizeof(int));

	// Open output file for writing
	if (g_bReportAll)
	{
		fp = fopen(szOutFile, "wt");
		if (fp == NULL)
		{
			printf("main: failed to open '%s'\n", szOutFile);
			return false;
		}
	}
	
	// Open statt file for writing
	FILE* fp2 = fopen(szStatFile, "wt");
	if (fp2 == NULL)
	{
		fclose(fp);
		printf("main: failed to open '%s'\n", szStatFile);
		return false;
	}

	// Open two needed db connections
	g_pdbcon1 = new mysqlpp::Connection(mysqlpp::use_exceptions);
	g_pdbcon2 = new mysqlpp::Connection(mysqlpp::use_exceptions);
	g_pdbcon1->connect(MYSQL_DATABASE, MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
	g_pdbcon2->connect(MYSQL_DATABASE, MYSQL_HOST, MYSQL_USER, MYSQL_PASS);

	// Print header for stats file
	GetKeyNames(szTable);
	fprintf(fp2, "# Table = '%s'\n", szTable);
	fprintf(fp2, "# TOLERANCE ");
	for (i = 0; i < g_nKeys; i++)
		fprintf(fp2, "%s SUMHITS ", g_vStrKeys[i].c_str());
	fprintf(fp2, "\n");
	//fprintf(fp2, "SUMHITS\n");

	// Loop through tolerance values (given in percents)
	//float afTols[] = { 3.2f, 1.0f, 0.32f, 0.1f, 0.032f, 0.01f };
	//float afTols[] = {.32f};
	//float afTols[] = { .01f, .02f, .04f, .08f, .16f, .32f, .64f, 1.28f, 2.56f, 5.12f };
	//for (i = 0; i < sizeof(afTols)/sizeof(float); i++)  
	for (float j = .01; j < 6; j*=1.2)
	{
		ResetCounters(true);
		//g_fSumToler = afTols[i];
		g_fSumToler = j;
		fprintf(fp2, "%8f  ", g_fSumToler);
		
		for (g_i = g_nKeys - 1 ; g_i < g_nKeys; g_i++) //skip every other key w +=2
		{
			ResetCounters(false);
			// Find file similarities
			if (strlen(szMatchFile) > 1)
				FindSimilaritiesForOne(fp, szTable, szMatchFile);
			else
				FindSimilaritiesForAll(fp, szTable);
			fprintf(fp2, "%8d ", g_pnKeyHits[g_i]);
			fprintf(fp2, "%8d ", g_pnSumHits[g_i]);
			
			if (g_bReport)
				printf("Tolerance = %f, Key = : %d\n", g_fSumToler, g_i+1);
		}
		fprintf(fp2, "\n");
	}
	
	fprintf(fp2, "\n# Rows = %d\n", g_nRows);
	fprintf(fp2, "# Total Size = %d\n", g_nDataSize);
	fprintf(fp2, "# Identical = %d\n", g_nIdentical);
	for (i = 0; i < g_nKeys; i++)
		fprintf(fp2, "# '%s' Collisions = %d\n", g_vStrKeys[i].c_str(), g_pnCollisions[i]);

	fclose(fp);
	fclose(fp2);
	delete g_pdbcon1;
	delete g_pdbcon2;
	free(g_pnKeyHits);
	free(g_pnCollisions);
	return 0;
}
Example #10
0
WebPAnimEncoder* WebPAnimEncoderNewInternal(
    int width, int height, const WebPAnimEncoderOptions* enc_options,
    int abi_version) {
  WebPAnimEncoder* enc;

  if (WEBP_ABI_IS_INCOMPATIBLE(abi_version, WEBP_MUX_ABI_VERSION)) {
    return NULL;
  }
  if (width <= 0 || height <= 0 ||
      (width * (uint64_t)height) >= MAX_IMAGE_AREA) {
    return NULL;
  }

  enc = (WebPAnimEncoder*)WebPSafeCalloc(1, sizeof(*enc));
  if (enc == NULL) return NULL;
  // sanity inits, so we can call WebPAnimEncoderDelete():
  enc->encoded_frames_ = NULL;
  enc->mux_ = NULL;

  // Dimensions and options.
  *(int*)&enc->canvas_width_ = width;
  *(int*)&enc->canvas_height_ = height;
  if (enc_options != NULL) {
    *(WebPAnimEncoderOptions*)&enc->options_ = *enc_options;
    SanitizeEncoderOptions((WebPAnimEncoderOptions*)&enc->options_);
  } else {
    DefaultEncoderOptions((WebPAnimEncoderOptions*)&enc->options_);
  }

  // Canvas buffers.
  if (!WebPPictureInit(&enc->curr_canvas_copy_) ||
      !WebPPictureInit(&enc->prev_canvas_) ||
      !WebPPictureInit(&enc->prev_canvas_disposed_)) {
    return NULL;
  }
  enc->curr_canvas_copy_.width = width;
  enc->curr_canvas_copy_.height = height;
  enc->curr_canvas_copy_.use_argb = 1;
  if (!WebPPictureAlloc(&enc->curr_canvas_copy_) ||
      !WebPPictureCopy(&enc->curr_canvas_copy_, &enc->prev_canvas_) ||
      !WebPPictureCopy(&enc->curr_canvas_copy_, &enc->prev_canvas_disposed_)) {
    goto Err;
  }
  WebPUtilClearPic(&enc->prev_canvas_, NULL);
  enc->curr_canvas_copy_modified_ = 1;

  // Encoded frames.
  ResetCounters(enc);
  // Note: one extra storage is for the previous frame.
  enc->size_ = enc->options_.kmax - enc->options_.kmin + 1;
  // We need space for at least 2 frames. But when kmin, kmax are both zero,
  // enc->size_ will be 1. So we handle that special case below.
  if (enc->size_ < 2) enc->size_ = 2;
  enc->encoded_frames_ =
      (EncodedFrame*)WebPSafeCalloc(enc->size_, sizeof(*enc->encoded_frames_));
  if (enc->encoded_frames_ == NULL) goto Err;

  enc->mux_ = WebPMuxNew();
  if (enc->mux_ == NULL) goto Err;

  enc->count_since_key_frame_ = 0;
  enc->first_timestamp_ = 0;
  enc->prev_timestamp_ = 0;
  enc->prev_candidate_undecided_ = 0;
  enc->is_first_frame_ = 1;
  enc->got_null_frame_ = 0;

  return enc;  // All OK.

 Err:
  WebPAnimEncoderDelete(enc);
  return NULL;
}