本文整理汇总了C++中SCOPED_TIMER函数的典型用法代码示例。如果您正苦于以下问题:C++ SCOPED_TIMER函数的具体用法?C++ SCOPED_TIMER怎么用?C++ SCOPED_TIMER使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SCOPED_TIMER函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SCOPED_TIMER
void ProfileDrawer::DrawScreen()
{
SCOPED_TIMER("ProfileDrawer");
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0,1,0,1);
glDisable(GL_TEXTURE_2D);
font->Begin();
font->SetTextColor(1,1,0.5f,0.8f);
DrawThreadBarcode();
DrawFrameBarcode();
DrawProfiler();
DrawInfoText();
font->End();
glColor4f(1.0f,1.0f,1.0f,1.0f);
glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
示例2: CmdLineParams
/**
* @param argc argument count
* @param argv array of argument strings
*
* Executes the application
* (contains main game loop)
*/
int SpringApp::Run(int argc, char *argv[])
{
cmdline = new CmdLineParams(argc, argv);
binaryName = argv[0];
if (!Initialize())
return -1;
GML::Init();
while (!gu->globalQuit) {
ResetScreenSaverTimeout();
{
SCOPED_TIMER("InputHandler::PushEvents");
SDL_Event event;
while (SDL_PollEvent(&event)) {
input.PushEvent(event);
}
}
if (!Update())
break;
}
SaveWindowPosition();
// Shutdown
Shutdown();
return 0;
}
示例3: SCOPED_TIMER
void CPathManager::Update()
{
SCOPED_TIMER("PFS Update");
maxResPF->UpdateHeatMap();
medResPE->Update();
lowResPE->Update();
}
示例4: SCOPED_TIMER
/*
Request a new multipath, store the result and return a handle-id to it.
*/
unsigned int CPathManager::RequestPath(
CSolidObject* caller,
const MoveDef* moveDef,
float3 startPos,
float3 goalPos,
float goalRadius,
bool synced
) {
if (!IsFinalized())
return 0;
// in misc since it is called from many points
SCOPED_TIMER("Misc::Path::RequestPath");
startPos.ClampInBounds();
goalPos.ClampInBounds();
// Create an estimator definition.
goalRadius = std::max<float>(goalRadius, PATH_NODE_SPACING * SQUARE_SIZE); //FIXME do on a per PE & PF level?
assert(moveDef == moveDefHandler->GetMoveDefByPathType(moveDef->pathType));
MultiPath newPath = MultiPath(moveDef, startPos, goalPos, goalRadius);
newPath.finalGoal = goalPos;
newPath.caller = caller;
newPath.peDef.synced = synced;
if (caller != nullptr)
caller->UnBlock();
const IPath::SearchResult result = ArrangePath(&newPath, moveDef, startPos, goalPos, caller);
unsigned int pathID = 0;
if (result != IPath::Error) {
if (newPath.maxResPath.path.empty()) {
if (result != IPath::CantGetCloser) {
LowRes2MedRes(newPath, startPos, caller, synced);
MedRes2MaxRes(newPath, startPos, caller, synced);
} else {
// add one dummy waypoint so that the calling MoveType
// does not consider this request a failure, which can
// happen when startPos is very close to goalPos
//
// otherwise, code relying on MoveType::progressState
// (eg. BuilderCAI::MoveInBuildRange) would misbehave
// (eg. reject build orders)
newPath.maxResPath.path.push_back(startPos);
newPath.maxResPath.squares.push_back(int2(startPos.x / SQUARE_SIZE, startPos.z / SQUARE_SIZE));
}
}
FinalizePath(&newPath, startPos, goalPos, result == IPath::CantGetCloser);
newPath.searchResult = result;
pathID = Store(newPath);
}
if (caller != nullptr)
caller->Block();
return pathID;
}
示例5: SCOPED_TIMER
void CGrassDrawer::Draw()
{
if (grassOff || !readMap->GetGrassShadingTexture())
return;
SCOPED_TIMER("Draw::World::Foliage::Grass");
glPushAttrib(GL_CURRENT_BIT);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
if (!blockDrawer.inviewGrass.empty()) {
SetupGlStateNear();
DrawNear(blockDrawer.inviewGrass);
ResetGlStateNear();
}
// ATI crashes w/o an error when shadows are enabled!?
static const bool shaders = globalRendering->haveGLSL;
const bool shadows = (shadowHandler->ShadowsLoaded() && globalRendering->atiHacks);
if (shaders && !shadows && (!blockDrawer.inviewFarGrass.empty() || !blockDrawer.inviewNearGrass.empty())) {
SetupGlStateFar();
DrawFarBillboards(blockDrawer.inviewFarGrass);
DrawNearBillboards(blockDrawer.inviewNearGrass);
ResetGlStateFar();
}
glPopAttrib();
}
示例6: SCOPED_TIMER
void CCobEngine::Tick(int deltaTime)
{
SCOPED_TIMER("Scripts");
GCurrentTime += deltaTime;
#if COB_DEBUG > 0
logOutput.Print("----");
#endif
// Advance all running threads
for (std::list<CCobThread *>::iterator i = running.begin(); i != running.end(); ++i) {
//logOutput.Print("Now 1running %d: %s", GCurrentTime, (*i)->GetName().c_str());
#ifdef _CONSOLE
printf("----\n");
#endif
TickThread(deltaTime, *i);
}
// A thread can never go from running->running, so clear the list
// note: if preemption was to be added, this would no longer hold
// however, ta scripts can not run preemptively anyway since there
// isn't any synchronization methods available
running.clear();
// The threads that just ran may have added new threads that should run next tick
for (std::list<CCobThread *>::iterator i = wantToRun.begin(); i != wantToRun.end(); ++i) {
running.push_front(*i);
}
wantToRun.clear();
//Check on the sleeping threads
if (!sleeping.empty()) {
CCobThread *cur = sleeping.top();
while ((cur != NULL) && (cur->GetWakeTime() < GCurrentTime)) {
// Start with removing the executing thread from the queue
sleeping.pop();
//Run forward again. This can quite possibly readd the thread to the sleeping array again
//But it will not interfere since it is guaranteed to sleep > 0 ms
//logOutput.Print("Now 2running %d: %s", GCurrentTime, cur->GetName().c_str());
#ifdef _CONSOLE
printf("+++\n");
#endif
if (cur->state == CCobThread::Sleep) {
cur->state = CCobThread::Run;
TickThread(deltaTime, cur);
} else if (cur->state == CCobThread::Dead) {
delete cur;
} else {
logOutput.Print("CobError: Sleeping thread strange state %d", cur->state);
}
if (!sleeping.empty())
cur = sleeping.top();
else
cur = NULL;
}
}
}
示例7: SCOPED_TIMER
void CDecalsDrawerGL4::FreeDecal(int idx)
{
if (idx == 0)
return;
SCOPED_TIMER("DecalsDrawerGL4::Update");
Decal& d = decals[idx];
if ((d.owner == nullptr) && (d.type == Decal::BUILDING)) {
auto it = spring::find(alphaDecayingDecals, idx);
assert(it != alphaDecayingDecals.end());
alphaDecayingDecals.erase(it);
}
d = Decal();
decalsToUpdate.push_back(idx);
freeIds.push_back(idx);
// we were the worst rated decal? -> find new one
if (idx == curWorstDecalIdx) {
GetWorstRatedDecal(&curWorstDecalIdx, &curWorstDecalRating, false);
}
RemoveFromGroup(idx);
}
示例8: SCOPED_TIMER
void CGroupHandler::Update()
{
SCOPED_TIMER("Group AI");
for(std::vector<CGroup*>::iterator ai=groups.begin();ai!=groups.end();++ai)
if((*ai)!=0)
(*ai)->Update();
}
示例9: SCOPED_TIMER
void CGrassDrawer::Draw()
{
if (grassOff || !readMap->GetGrassShadingTexture())
return;
SCOPED_TIMER("Grass::Draw");
glPushAttrib(GL_CURRENT_BIT);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
if (!blockDrawer.inviewGrass.empty()) {
SetupGlStateNear();
DrawNear(blockDrawer.inviewGrass);
ResetGlStateNear();
}
if (
globalRendering->haveGLSL
&& (!shadowHandler->shadowsLoaded || !globalRendering->atiHacks) // Ati crashes w/o an error when shadows are enabled!?
&& !(blockDrawer.inviewFarGrass.empty() && blockDrawer.inviewNearGrass.empty())
) {
SetupGlStateFar();
DrawFarBillboards(blockDrawer.inviewFarGrass);
DrawNearBillboards(blockDrawer.inviewNearGrass);
ResetGlStateFar();
}
glPopAttrib();
}
示例10: SCOPED_TIMER
void CPathManager::Update()
{
SCOPED_TIMER("PFS Update");
pf->UpdateHeatMap();
pe->Update();
pe2->Update();
}
示例11: SCOPED_TIMER
CSkirmishAI::~CSkirmishAI() {
SCOPED_TIMER(timerName.c_str());
if (initOk) {
library->Release(teamId);
}
IAILibraryManager::GetInstance()->ReleaseSkirmishAILibrary(key);
}
示例12: SCOPED_TIMER
/*
Removes and return the next waypoint in the multipath corresponding to given id.
*/
float3 CPathManager::NextWaypoint(unsigned int pathId, float3 callerPos, float minDistance,
int numRetries, int ownerId) const
{
SCOPED_TIMER("PFS");
//0 indicate a no-path id.
if(pathId == 0)
return float3(-1,-1,-1);
if(numRetries>4)
return float3(-1,-1,-1);
//Find corresponding multipath.
std::map<unsigned int, MultiPath*>::const_iterator pi = pathMap.find(pathId);
if(pi == pathMap.end())
return float3(-1,-1,-1);
MultiPath* multiPath = pi->second;
if(callerPos==ZeroVector){
if(!multiPath->detailedPath.path.empty())
callerPos=multiPath->detailedPath.path.back();
}
//check if detailed path need bettering
if(!multiPath->estimatedPath.path.empty()
&& (multiPath->estimatedPath.path.back().SqDistance2D(callerPos) < Square(MIN_DETAILED_DISTANCE * SQUARE_SIZE)
|| multiPath->detailedPath.path.size() <= 2)){
if(!multiPath->estimatedPath2.path.empty() //if so check if estimated path also need bettering
&& (multiPath->estimatedPath2.path.back().SqDistance2D(callerPos) < Square(MIN_ESTIMATE_DISTANCE * SQUARE_SIZE)
|| multiPath->estimatedPath.path.size() <= 2)){
Estimate2ToEstimate(*multiPath, callerPos, ownerId);
}
if(multiPath->caller)
multiPath->caller->UnBlock();
EstimateToDetailed(*multiPath, callerPos, ownerId);
if(multiPath->caller)
multiPath->caller->Block();
}
//Repeat until a waypoint distant enought are found.
float3 waypoint;
do {
//Get next waypoint.
if(multiPath->detailedPath.path.empty()) {
if(multiPath->estimatedPath2.path.empty() && multiPath->estimatedPath.path.empty())
return multiPath->finalGoal;
else
return NextWaypoint(pathId,callerPos,minDistance,numRetries+1,ownerId);
} else {
waypoint = multiPath->detailedPath.path.back();
multiPath->detailedPath.path.pop_back();
}
} while(callerPos.SqDistance2D(waypoint) < Square(minDistance) && waypoint != multiPath->detailedPath.pathGoal);
return waypoint;
}
示例13: SCOPED_TIMER
void CBasicMapDamage::Update()
{
SCOPED_TIMER("BasicMapDamage::Update");
std::deque<Explo*>::iterator ei;
for (ei = explosions.begin(); ei != explosions.end(); ++ei) {
Explo* e = *ei;
if (e->ttl <= 0) {
continue;
}
--e->ttl;
const int x1 = e->x1;
const int x2 = e->x2;
const int y1 = e->y1;
const int y2 = e->y2;
std::vector<float>::const_iterator si = e->squares.begin();
for (int y = y1; y <= y2; ++y) {
for (int x = x1; x<= x2; ++x) {
const float dif = *(si++);
readMap->AddHeight(y * gs->mapxp1 + x, dif);
}
}
std::vector<ExploBuilding>::const_iterator bi;
for (bi = e->buildings.begin(); bi != e->buildings.end(); ++bi) {
const float dif = bi->dif;
const int tx1 = bi->tx1;
const int tx2 = bi->tx2;
const int tz1 = bi->tz1;
const int tz2 = bi->tz2;
for (int z = tz1; z < tz2; z++) {
for (int x = tx1; x < tx2; x++) {
readMap->AddHeight(z * gs->mapxp1 + x, dif);
}
}
CUnit* unit = unitHandler->GetUnit(bi->id);
if (unit != NULL) {
unit->Move(UpVector * dif, true);
}
}
if (e->ttl == 0) {
RecalcArea(x1 - 2, x2 + 2, y1 - 2, y2 + 2);
}
}
while (!explosions.empty() && explosions.front()->ttl == 0) {
delete explosions.front();
explosions.pop_front();
}
UpdateLos();
}
示例14: SCOPED_TIMER
void BlockDataViewer::enableZeroConf(bool clearMempool)
{
SCOPED_TIMER("enableZeroConf");
LOGINFO << "Enabling zero-conf tracking ";
zcEnabled_ = true;
//zcLiteMode_ = zcLite;
auto zcFilter = [this](const BinaryData& scrAddr)->bool
{ return this->bdmPtr_->getScrAddrFilter()->hasScrAddress(scrAddr); };
zeroConfCont_.loadZeroConfMempool(zcFilter, clearMempool);
}
示例15: teamId
CSkirmishAI::CSkirmishAI(int teamId, const SkirmishAIKey& key,
const SSkirmishAICallback* c_callback) :
teamId(teamId),
key(key),
timerName("AI t:" + IntToString(teamId) + " " +
key.GetShortName() + " " + key.GetVersion()),
dieing(false)
{
SCOPED_TIMER(timerName.c_str());
library = IAILibraryManager::GetInstance()->FetchSkirmishAILibrary(key);
initOk = library->Init(teamId, c_callback);
}