当前位置: 首页>>代码示例>>C++>>正文


C++ CStopWatch::getDiff方法代码示例

本文整理汇总了C++中CStopWatch::getDiff方法的典型用法代码示例。如果您正苦于以下问题:C++ CStopWatch::getDiff方法的具体用法?C++ CStopWatch::getDiff怎么用?C++ CStopWatch::getDiff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CStopWatch的用法示例。


在下文中一共展示了CStopWatch::getDiff方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

void CMapHandler::init()
{
	CStopWatch th;
	th.getDiff();

	graphics->advmapobjGraphics["AB01_.DEF"] = graphics->boatAnims[0];
	graphics->advmapobjGraphics["AB02_.DEF"] = graphics->boatAnims[1];
	graphics->advmapobjGraphics["AB03_.DEF"] = graphics->boatAnims[2];
	// Size of visible terrain.
	int mapW = conf.go()->ac.advmapW;
	int mapH = conf.go()->ac.advmapH;

	//sizes of terrain
	sizes.x = map->width;
	sizes.y = map->height;
	sizes.z = map->twoLevel ? 2 : 1;

	// Total number of visible tiles. Subtract the center tile, then
	// compute the number of tiles on each side, and reassemble.
	int t1, t2;
	t1 = (mapW-32)/2;
	t2 = mapW - 32 - t1;
	tilesW = 1 + (t1+31)/32 + (t2+31)/32;

	t1 = (mapH-32)/2;
	t2 = mapH - 32 - t1;
	tilesH = 1 + (t1+31)/32 + (t2+31)/32;

	// Size of the frame around the map. In extremes positions, the
	// frame must not be on the center of the map, but right on the
	// edge of the center tile.
	frameW = (mapW+31) /32 / 2;
	frameH = (mapH+31) /32 / 2;

	offsetX = (mapW - (2*frameW+1)*32)/2;
	offsetY = (mapH - (2*frameH+1)*32)/2;

	for(int i=0;i<map->heroes.size();i++)
	{
		if( !graphics->getDef(map->heroes[i]) )
		{
			initHeroDef(map->heroes[i]);
		}
	}

    std::for_each(map->customDefs.begin(),map->customDefs.end(),processDef); //load h3m defs
    logGlobal->infoStream()<<"\tUnpacking and handling defs: "<<th.getDiff();

	prepareFOWDefs();
	roadsRiverTerrainInit();	//road's and river's DefHandlers; and simple values initialization
	borderAndTerrainBitmapInit();
    logGlobal->infoStream()<<"\tPreparing FoW, roads, rivers,borders: "<<th.getDiff();
	initObjectRects();
    logGlobal->infoStream()<<"\tMaking object rects: "<<th.getDiff();

}
开发者ID:vargad,项目名称:vcmi,代码行数:56,代码来源:mapHandler.cpp

示例2: loadHeroFlags

void Graphics::loadHeroFlags()
{
	using namespace boost::assign;
	CStopWatch th;
	std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > pr[4];
	pr[0].first = &Graphics::flags1;
	pr[0].second+=("ABF01L.DEF"),("ABF01G.DEF"),("ABF01R.DEF"),("ABF01D.DEF"),("ABF01B.DEF"),
		("ABF01P.DEF"),("ABF01W.DEF"),("ABF01K.DEF");
	pr[1].first = &Graphics::flags2;
	pr[1].second+=("ABF02L.DEF"),("ABF02G.DEF"),("ABF02R.DEF"),("ABF02D.DEF"),("ABF02B.DEF"),
		("ABF02P.DEF"),("ABF02W.DEF"),("ABF02K.DEF");
	pr[2].first = &Graphics::flags3;
	pr[2].second+=("ABF03L.DEF"),("ABF03G.DEF"),("ABF03R.DEF"),("ABF03D.DEF"),("ABF03B.DEF"),
		("ABF03P.DEF"),("ABF03W.DEF"),("ABF03K.DEF");
	pr[3].first = &Graphics::flags4;
	pr[3].second+=("AF00.DEF"),("AF01.DEF"),("AF02.DEF"),("AF03.DEF"),("AF04.DEF"),
		("AF05.DEF"),("AF06.DEF"),("AF07.DEF");
	boost::thread_group grupa;
	for(int g=3; g>=0; --g)
	{
		grupa.create_thread(boost::bind(&Graphics::loadHeroFlagsDetail, this, boost::ref(pr[g]), true));
	}
	grupa.join_all();
    logGlobal->infoStream() << "Loading and transforming heroes' flags: "<<th.getDiff();
}
开发者ID:andrew889,项目名称:vcmi,代码行数:25,代码来源:Graphics.cpp

示例3: loadFilesystem

void LibClasses::loadFilesystem()
{
	CStopWatch totalTime;
	CStopWatch loadTime;

	CResourceHandler::initialize();
	tlog0<<"\t Initialization: "<<loadTime.getDiff()<<std::endl;

	CResourceHandler::loadFileSystem("", "ALL/config/filesystem.json");
	tlog0<<"\t Data loading: "<<loadTime.getDiff()<<std::endl;

	modh = new CModHandler;
	tlog0<<"\tMod handler: "<<loadTime.getDiff()<<std::endl;

	modh->initialize(CResourceHandler::getAvailableMods());
	CResourceHandler::setActiveMods(modh->getActiveMods());
	tlog0<<"\t Mod filesystems: "<<loadTime.getDiff()<<std::endl;

	tlog0<<"Basic initialization: "<<totalTime.getDiff()<<std::endl;
}
开发者ID:Ed-von-Schleck,项目名称:vcmi,代码行数:20,代码来源:VCMI_Lib.cpp

示例4: loadFilesystem

void LibClasses::loadFilesystem()
{
	CStopWatch totalTime;
	CStopWatch loadTime;

	CResourceHandler::initialize();
	logGlobal->infoStream()<<"\t Initialization: "<<loadTime.getDiff();

	CResourceHandler::load("config/filesystem.json");
	logGlobal->infoStream()<<"\t Data loading: "<<loadTime.getDiff();

	modh = new CModHandler;
	logGlobal->infoStream()<<"\tMod handler: "<<loadTime.getDiff();

	modh->loadMods();
	modh->loadModFilesystems();
	logGlobal->infoStream()<<"\t Mod filesystems: "<<loadTime.getDiff();

	logGlobal->infoStream()<<"Basic initialization: "<<totalTime.getDiff();
}
开发者ID:DavidZeni,项目名称:vcmi,代码行数:20,代码来源:VCMI_Lib.cpp

示例5: loadHeroFlags

void Graphics::loadHeroFlags()
{
	CStopWatch th;
	std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > pr[4] =
	{
		{
			&Graphics::flags1,
			{"ABF01L.DEF","ABF01G.DEF","ABF01R.DEF","ABF01D.DEF","ABF01B.DEF",
			"ABF01P.DEF","ABF01W.DEF","ABF01K.DEF"}
		},
		{
			&Graphics::flags2,
			{"ABF02L.DEF","ABF02G.DEF","ABF02R.DEF","ABF02D.DEF","ABF02B.DEF",
			"ABF02P.DEF","ABF02W.DEF","ABF02K.DEF"}

		},
		{
			&Graphics::flags3,
			{"ABF03L.DEF","ABF03G.DEF","ABF03R.DEF","ABF03D.DEF","ABF03B.DEF",
			"ABF03P.DEF","ABF03W.DEF","ABF03K.DEF"}
		},
		{
			&Graphics::flags4,
			{"AF00.DEF","AF01.DEF","AF02.DEF","AF03.DEF","AF04.DEF",
			"AF05.DEF","AF06.DEF","AF07.DEF"}
		}
	};

	#if 0
	boost::thread_group grupa;
	for(int g=3; g>=0; --g)
	{
		grupa.create_thread(std::bind(&Graphics::loadHeroFlagsDetail, this, std::ref(pr[g]), true));
	}
	grupa.join_all();
	#else
	for(auto p: pr)
	{
		loadHeroFlagsDetail(p,true);
	}
	#endif
	logGlobal->infoStream() << "Loading and transforming heroes' flags: "<<th.getDiff();
}
开发者ID:,项目名称:,代码行数:43,代码来源:

示例6: logHandlerLoaded

static void logHandlerLoaded(const std::string& name, CStopWatch &timer)
{
   tlog0<<"\t" << name << " handler: "<<timer.getDiff()<<std::endl;
};
开发者ID:Ed-von-Schleck,项目名称:vcmi,代码行数:4,代码来源:VCMI_Lib.cpp

示例7: loadGame

void CClient::loadGame(const std::string & fname, const bool server, const std::vector<int>& humanplayerindices, const int loadNumPlayers, int player_, const std::string & ipaddr, const std::string & port)
{
    PlayerColor player(player_); //intentional shadowing

    logNetwork->infoStream() <<"Loading procedure started!";

	CServerHandler sh;
    if(server)
         sh.startServer();
    else
         serv = sh.justConnectToServer(ipaddr,port=="" ? "3030" : port);

	CStopWatch tmh;
    unique_ptr<CLoadFile> loader;
	try
	{
		std::string clientSaveName = *CResourceHandler::get("local")->getResourceName(ResourceID(fname, EResType::CLIENT_SAVEGAME));
		std::string controlServerSaveName;

		if (CResourceHandler::get("local")->existsResource(ResourceID(fname, EResType::SERVER_SAVEGAME)))
		{
			controlServerSaveName = *CResourceHandler::get("local")->getResourceName(ResourceID(fname, EResType::SERVER_SAVEGAME));
		}
		else// create entry for server savegame. Triggered if save was made after launch and not yet present in res handler
		{
			controlServerSaveName = clientSaveName.substr(0, clientSaveName.find_last_of(".")) + ".vsgm1";
			CResourceHandler::get("local")->createResource(controlServerSaveName, true);
		}

		if(clientSaveName.empty())
			throw std::runtime_error("Cannot open client part of " + fname);
		if(controlServerSaveName.empty())
			throw std::runtime_error("Cannot open server part of " + fname);

		{
			CLoadIntegrityValidator checkingLoader(clientSaveName, controlServerSaveName, minSupportedVersion);
			loadCommonState(checkingLoader);
			loader = checkingLoader.decay();
		}
        logNetwork->infoStream() << "Loaded common part of save " << tmh.getDiff();
		const_cast<CGameInfo*>(CGI)->mh = new CMapHandler();
		const_cast<CGameInfo*>(CGI)->mh->map = gs->map;
		pathInfo = make_unique<CPathsInfo>(getMapSize());
		CGI->mh->init();
        logNetwork->infoStream() <<"Initing maphandler: "<<tmh.getDiff();
	}
	catch(std::exception &e)
	{
		logGlobal->errorStream() << "Cannot load game " << fname << ". Error: " << e.what();
		throw; //obviously we cannot continue here
	}

/*
    if(!server)
         player = PlayerColor(player_);
*/

    std::set<PlayerColor> clientPlayers;
    if(server)
         serv = sh.connectToServer();
    //*loader >> *this;

    if(server)
    {
         tmh.update();
         ui8 pom8;
         *serv << ui8(3) << ui8(loadNumPlayers); //load game; one client if single-player
         *serv << fname;
         *serv >> pom8;
         if(pom8) 
              throw std::runtime_error("Server cannot open the savegame!");
         else
              logNetwork->infoStream() << "Server opened savegame properly.";
    }

    if(server)
    {
         for(auto & elem : gs->scenarioOps->playerInfos)
              if(!std::count(humanplayerindices.begin(),humanplayerindices.end(),elem.first.getNum()) || elem.first==player)
              {
                  clientPlayers.insert(elem.first);
              }
         clientPlayers.insert(PlayerColor::NEUTRAL);
    }
    else
    {
        clientPlayers.insert(player);
    }

    std::cout << "CLIENTPLAYERS:\n";
    for(auto x : clientPlayers)
         std::cout << x << std::endl;
    std::cout << "ENDCLIENTPLAYERS\n";

    serialize(loader->serializer,0,clientPlayers);
    *serv << ui32(clientPlayers.size());
    for(auto & elem : clientPlayers)
        *serv << ui8(elem.getNum());
    serv->addStdVecItems(gs); /*why is this here?*/

//.........这里部分代码省略.........
开发者ID:DavidZeni,项目名称:vcmi,代码行数:101,代码来源:Client.cpp

示例8: logHandlerLoaded

static void logHandlerLoaded(const std::string& name, CStopWatch &timer)
{
   logGlobal->infoStream()<<"\t\t" << name << " handler: "<<timer.getDiff();
};
开发者ID:DavidZeni,项目名称:vcmi,代码行数:4,代码来源:VCMI_Lib.cpp

示例9: loadGame

void CClient::loadGame( const std::string & fname )
{
    logNetwork->infoStream() <<"Loading procedure started!";

	CServerHandler sh;
	sh.startServer();

	CStopWatch tmh;
	try
	{
		std::string clientSaveName = CResourceHandler::get()->getResourceName(ResourceID(fname, EResType::CLIENT_SAVEGAME));
		std::string controlServerSaveName;

		if (CResourceHandler::get()->existsResource(ResourceID(fname, EResType::SERVER_SAVEGAME)))
		{
			controlServerSaveName = CResourceHandler::get()->getResourceName(ResourceID(fname, EResType::SERVER_SAVEGAME));
		}
		else// create entry for server savegame. Triggered if save was made after launch and not yet present in res handler
		{
			controlServerSaveName = clientSaveName.substr(0, clientSaveName.find_last_of(".")) + ".vsgm1";
			CResourceHandler::get()->createResource(controlServerSaveName, true);
		}

		if(clientSaveName.empty())
			throw std::runtime_error("Cannot open client part of " + fname);
		if(controlServerSaveName.empty())
			throw std::runtime_error("Cannot open server part of " + fname);

		unique_ptr<CLoadFile> loader;
		{
			CLoadIntegrityValidator checkingLoader(clientSaveName, controlServerSaveName);
			loadCommonState(checkingLoader);
			loader = checkingLoader.decay();
		}
        logNetwork->infoStream() << "Loaded common part of save " << tmh.getDiff();
		const_cast<CGameInfo*>(CGI)->mh = new CMapHandler();
		const_cast<CGameInfo*>(CGI)->mh->map = gs->map;
		pathInfo = make_unique<CPathsInfo>(getMapSize());
		CGI->mh->init();
        logNetwork->infoStream() <<"Initing maphandler: "<<tmh.getDiff();

		*loader >> *this;
        logNetwork->infoStream() << "Loaded client part of save " << tmh.getDiff();
	}
	catch(std::exception &e)
	{
		logGlobal->errorStream() << "Cannot load game " << fname << ". Error: " << e.what();
		throw; //obviously we cannot continue here
	}

	serv = sh.connectToServer();
	serv->addStdVecItems(gs);

	tmh.update();
	ui8 pom8;
	*serv << ui8(3) << ui8(1); //load game; one client
	*serv << fname;
	*serv >> pom8;
	if(pom8) 
		throw std::runtime_error("Server cannot open the savegame!");
	else
        logNetwork->infoStream() << "Server opened savegame properly.";

	*serv << ui32(gs->scenarioOps->playerInfos.size()+1); //number of players + neutral
	for(auto it = gs->scenarioOps->playerInfos.begin(); 
		it != gs->scenarioOps->playerInfos.end(); ++it)
	{
		*serv << ui8(it->first.getNum()); //players
	}
	*serv << ui8(PlayerColor::NEUTRAL.getNum());
    logNetwork->infoStream() <<"Sent info to server: "<<tmh.getDiff();

	serv->enableStackSendingByID();
	serv->disableSmartPointerSerialization();

}
开发者ID:lightsgoout,项目名称:vcmi,代码行数:76,代码来源:Client.cpp


注:本文中的CStopWatch::getDiff方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。