CCorePrintRegisterTickNumJob::~CCorePrintRegisterTickNumJob()
{
	size_t stNum = CSyncTimeSystemServer::Inst()->GetRegisterTickNum();

	const char* mode = gs_bTickLogExist ? "ab" : "wb";
	if(!gs_bTickLogExist)
		gs_bTickLogExist = true;

	char buf[256];
	sprintf(buf, "Tick_%d.log", GetCurPID());
	CLog* pLog = CLog::CreateLog(buf, mode);

	sprintf(buf, "逻辑线程CppTick数量: %u\t\t逻辑线程LuaTick数量: %u\t\t引擎线程Tick数量: %u", (uint32)m_stCppTickNum, (uint32)m_stLuaTickNum, (uint32)stNum);

	pLog->EnableTime(false);
	pLog->Write(buf);

	pLog->Release();
}
CCorePrintRegisterTickInfoJob::~CCorePrintRegisterTickInfoJob()
{
	const char* mode = gs_bTickLogExist ? "ab" : "wb";
	if(!gs_bTickLogExist)
		gs_bTickLogExist = true;

	string strInfo;
	CSyncTimeSystemServer::Inst()->GetRegisterTickInfo(strInfo);

	
	char buf[256];
	sprintf(buf, "Tick_%d.log", GetCurPID());

	CLog* pLog = CLog::CreateLog(buf, mode);

	pLog->EnableTime(false);
	pLog->Write(m_strInfo->c_str());
	pLog->Write(strInfo.c_str());

	pLog->Release();

	delete m_strInfo;
}
Example #3
0
	int TraverseTable(lua_State* pState)
	{
		if(!lua_istable(pState, 1))
			return 0;

		string name;
		if (lua_isstring(pState, 2))
		{
			name = lua_tostring(pState, 2);
		}
		else
		{
			char buf[50];
			static int32 nNum = 0;
			sprintf(buf, "Trav%u_%u.log", Atomic_FetchAndAdd(&nNum, 1), GetCurPID());
			name = buf;
		}
		const char* mode = (lua_isstring(pState, 3)) ? (lua_tostring(pState, 3)) : "w";
		
		const int ls_nMaxTravelLevel = 10;

		int nMaxLevel = (lua_isnumber(pState, 4)) ? (int)lua_tonumber(pState, 4) : ls_nMaxTravelLevel;

		set<const void*> tbl;
		int level = -1;

		uint64 uBegin = GetProcessTime();

		//在travel的时候必须得关闭thread watch功能,因为travel可能会很慢
		HTHREAD hThread;
		GetCurrentThread(&hThread);
		EnableWatchThread(hThread, false);

		if (lua_istable(pState, 5))
		{
			//filter object table
			lua_checkstack(pState, 3);

			lua_pushnil(pState);

			while (lua_next(pState, -2))
			{
				const void* p = lua_topointer(pState, -1);
				tbl.insert(p);
				lua_pop(pState, 1);
			}
		}

		lua_settop(pState, 1);

		CLog* pLog = CLog::CreateLog(name.c_str(), mode);
		pLog->EnableTime(false);

		uint32 uDataNum = 0;
		_TraverseTable(pState, tbl, pLog, level, nMaxLevel, uDataNum);
		EnableWatchThread(hThread, true);

		uint64 uEnd = GetProcessTime();
		
		ostringstream strm;
		strm << endl;
		strm << "遍历花费时间: " << uEnd - uBegin << " 毫秒" << endl;

		pLog->Write(strm.str().c_str());

		pLog->Release();

		return 0;
	}