Exemplo n.º 1
0
// This function adds a graph_entry into the database periodically.
DWORD WINAPI PerfThreadFn( LPVOID pParameter )
{
	DWORD lastSent = 0;
	DWORD lastReceived = 0;
	DWORD startTicks = GetTickCount();

	while ( WaitForSingleObject( g_hPerfThreadExitEvent, 1000 ) != WAIT_OBJECT_0 )
	{
		PerfThread_AddGraphEntry( startTicks, lastSent, lastReceived );

		// Send updates for text output.
		PerfThread_SendSpewText();

		// If we're the master, update all the worker stats.
		if ( g_bMaster )
		{
			g_pDB->AddCommandToQueue( 
				new CSQLDBCommand_WorkerStats, 
				NULL );
		}
	}

	// Add the remaining text and one last graph entry (which will include the current stage info).
	PerfThread_SendSpewText();
	PerfThread_AddGraphEntry( startTicks, lastSent, lastReceived );

	SetEvent( g_hPerfThreadExitEvent );
	return 0;
}
Exemplo n.º 2
0
// This function adds a graph_entry into the database every few seconds.
DWORD WINAPI PerfThreadFn( LPVOID pParameter )
{
	DWORD lastSent = 0;
	DWORD lastReceived = 0;
	DWORD startTicks = GetTickCount();

	while ( WaitForSingleObject( g_hPerfThreadExitEvent, 1000 ) != WAIT_OBJECT_0 )
	{
		DWORD curSent = g_nBytesSent + g_nMulticastBytesSent;
		DWORD curReceived = g_nBytesReceived + g_nMulticastBytesReceived;

		g_pDB->AddCommandToQueue( 
			new CSQLDBCommand_GraphEntry( 
				GetTickCount() - startTicks,
				curSent - lastSent, 
				curReceived - lastReceived ), 
			NULL );

		PerfThread_SendSpewText();

		lastSent = curSent;
		lastReceived = curReceived;
	}

	PerfThread_SendSpewText();
	SetEvent( g_hPerfThreadExitEvent );
	return 0;
}