本文整理汇总了C++中Timer::GetElapsedTime方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::GetElapsedTime方法的具体用法?C++ Timer::GetElapsedTime怎么用?C++ Timer::GetElapsedTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::GetElapsedTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawFrame
/**
* Just the current frame in the display.
*/
void Engine::DrawFrame()
{
float fFPS;
if( monitor_.Update( fFPS ) )
{
UpdateFPS( fFPS );
}
//renderer_.Update( monitor_.GetCurrentTime() );
static Timer Timer;
static double PrevTime = Timer.GetElapsedTime();
auto CurrTime = Timer.GetElapsedTime();
auto ElapsedTime = CurrTime - PrevTime;
PrevTime = CurrTime;
sample_->Update(CurrTime, ElapsedTime);
//renderer_.Render();
sample_->Render();
// Draw tweak bars
TwDraw();
// Swap
pSwapChain_->Present();
//if( EGL_SUCCESS != pRenderDevice_->Present() )
//{
// UnloadResources();
// LoadResources();
//}
}
示例2: idleCB
void idleCB(void)
{
animTcl::checkEvents() ;
if( g_state == STATE_ANIMATE )
{
if( g_frameDumping == 0 )
GlobalResourceManager::use()->setActualTime( g_globalTimer.GetElapsedTime() );
else
{
GlobalResourceManager::use()->advanceActualTime( 0.33 );
}
glutPostRedisplay() ;
}
else if( g_state == STATE_SIMULATE )
{
GlobalResourceManager::use()->setActualTime( g_globalTimer.GetElapsedTime() );
SimulationStep() ;
glutPostRedisplay() ;
}
myIdleCB() ;
}
示例3: Test
void Test(TopSpin &tse, const char *prefix)
{
TopSpinState s(16, 4);
TopSpinState g(16, 4);
g.Reset();
tse.StoreGoal(g);
tse.SetPruneSuccessors(true);
IDAStar<TopSpinState, TopSpinAction> ida;
ida.SetUseBDPathMax(true);
std::vector<TopSpinAction> path1;
TopSpinState start;
Timer t1;
t1.StartTimer();
uint64_t nodes = 0;
double totaltime = 0;
for (int x = 0; x < 100; x++)
{
s = GetInstance(x, tse.GetWeighted());
g.Reset();
printf("Problem %d of %d\n", x+1, 100);
std::cout << "Searching from: " << std::endl << s << std::endl << g << std::endl;
Timer t;
t.StartTimer();
ida.GetPath(&tse, s, g, path1);
t.EndTimer();
totaltime += t.GetElapsedTime();
std::cout << "Path found, length " << path1.size() << " time:" << t.GetElapsedTime() << std::endl;
nodes += ida.GetNodesExpanded();
}
printf("%s: %1.2fs elapsed; %llu nodes expanded\n", prefix, t1.EndTimer(), nodes);
}
示例4: runProblemSet2
void runProblemSet2(char *problems, int multiplier)
{
Map *map = new Map(gDefaultMap);
map->Scale(512, 512);
msa = new MapSectorAbstraction(map, 8, multiplier);
Graph *g = msa->GetAbstractGraph(1);
GraphAbstractionHeuristic gah1(msa, 1);
GraphDistanceHeuristic localGDH(g);
localGDH.SetPlacement(kAvoidPlacement);
for (unsigned int x = 0; x < 10; x++)
localGDH.AddHeuristic();
GraphHeuristicContainer ghc(g);
GraphRefinementEnvironment env1(msa, 1, &localGDH);
GraphRefinementEnvironment env2(msa, 1, 0);
// ghc.AddHeuristic(&localGDH);
// ghc.AddHeuristic(&gah1);
env1.SetDirected(false);
FILE *f = fopen(problems, "r");
if (f == 0)
{
printf("Cannot open file: '%s'\n", problems);
exit(0);
}
Timer t;
printf("len\tnodes\ttoucht\tlen\ttime\tdiff_n\tdiff_t\tdiff_l\ttime\n");
while (!feof(f))
{
int from, to, cost;
if (fscanf(f, "%d\t%d\t%d\n", &from, &to, &cost) != 3)
break;
node *s1 = g->GetNode(from);
node *g1 = g->GetNode(to);
graphState gs, gg;
gs = s1->GetNum();
gg = g1->GetNum();
std::vector<graphState> thePath;
t.StartTimer();
astar.GetPath(&env2, gs, gg, thePath);
t.EndTimer();
printf("%d\t", cost);
printf("%llu\t%llu\t%1.2f\t%e\t",
astar.GetNodesExpanded(), astar.GetNodesTouched(),
env1.GetPathLength(thePath), t.GetElapsedTime());
t.StartTimer();
astar.GetPath(&env1, gs, gg, thePath);
t.EndTimer();
printf("%llu\t%llu\t%1.2f\t%e",
astar.GetNodesExpanded(), astar.GetNodesTouched(),
env1.GetPathLength(thePath), t.GetElapsedTime());
printf("\n");
}
fclose(f);
exit(0);
}
示例5: Update
// Updates the application state once per frame.
void SampleAppMain::Update()
{
// Update scene objects.
m_timer.Tick([&]()
{
static Timer timer;
static double PrevTime = timer.GetElapsedTime();
auto CurrTime = timer.GetElapsedTime();
auto ElapsedTime = CurrTime - PrevTime;
PrevTime = CurrTime;
m_pSample->Update(CurrTime, ElapsedTime);
});
}
示例6: STPTest
void STPTest(unsigned long , tKeyboardModifier , char)
{
MNPuzzleState tmp(4, 4);
mnp->StoreGoal(tmp);
IDAStar<MNPuzzleState, slideDir> ida;
std::vector<slideDir> path1;
MNPuzzleState s(4, 4);
MNPuzzleState g(4, 4);
//ida.SetUseBDPathMax(true);
Timer t;
t.StartTimer();
uint64_t nodes = 0;
for (int x = 0; x < 100; x++)
{
s = GetKorfInstance(x);
g.Reset();
std::cout << "Searching from: " << std::endl << s << std::endl << g << std::endl;
Timer t;
t.StartTimer();
ida.GetPath(mnp, s, g, path1);
t.EndTimer();
std::cout << "Path found, length " << path1.size() << " time:" << t.GetElapsedTime() << std::endl;
nodes += ida.GetNodesExpanded();
}
printf("%1.2fs elapsed; %llu nodes expanded\n", t.EndTimer(), nodes);
// for (int x = 0; x < mnp->histogram.size(); x++)
// {
// printf("%2d %d\n", x, mnp->histogram[x]);
// }
//
// mnp->PrintHStats();
}
示例7: Test_Timer
// ----------------------------------------------------------------------------
// Timer.h
bool Test_Timer()
{
TTRACE(_T("====================================================="));
{
Timer t;
t.Start();
Sleep(500);
TTRACE(_T("time=%f, elapsed=%f"), t.GetTime(), t.GetElapsedTime());
t.Stop();
Sleep(500);
TTRACE(_T("time=%f, elapsed=%f"), t.GetTime(), t.GetElapsedTime());
t.Start();
Sleep(500);
TTRACE(_T("time=%f, elapsed=%f"), t.GetTime(), t.GetElapsedTime());
}
return true;
}
示例8: MyDisplayHandler
void MyDisplayHandler(unsigned long windowID, tKeyboardModifier mod, char key)
{
switch (key)
{
case 'r': recording = !recording; break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
ts->ApplyAction(s, key-'0');
break;
case '\t':
if (mod != kShiftDown)
SetActivePort(windowID, (GetActivePort(windowID)+1)%GetNumPorts(windowID));
else
{
SetNumPorts(windowID, 1+(GetNumPorts(windowID)%MAXPORTS));
}
break;
case 'p':
break;
case 'o':
{
if (!ts) break;
if (mod == kShiftDown)
{
IDAStar<TopSpinState, TopSpinAction> ida;
std::vector<TopSpinAction> path1;
std::vector<TopSpinState> path2;
TopSpinState s(4, 4);
TopSpinState g(4, 4);
for (unsigned int x = 0; x < 500; x++)
{
std::vector<TopSpinAction> acts;
ts->GetActions(s, acts);
ts->ApplyAction(s, acts[random()%acts.size()]);
}
std::cout << "Searching from: " << std::endl << s << std::endl << g << std::endl;
Timer t;
t.StartTimer();
ida.GetPath(ts, s, g, path1);
t.EndTimer();
std::cout << "Path found, length " << path1.size() << " time:" << t.GetElapsedTime() << std::endl;
}
}
break;
default:
break;
}
}
示例9: resetTime
// resets time to 0.
void resetTime(void)
{
g_globalTimer.GetElapsedTime() ;
// reset the timer to point the current time
g_globalTimer.Reset() ;
GlobalResourceManager::use()->setActualTime( 0.0 );
GlobalResourceManager::use()->setSimulationTime( 0.0 );
}
示例10: DoBFS
void DoBFS()
{
// By default, starts at goal state
SlidingPuzzleState s;
LList<int> moves;
uint8_t *stateDepths = new uint8_t[s.GetMaxRank()];
// set all values to 255
memset(stateDepths, 255, s.GetMaxRank());
uint32_t seenStates = 1;
stateDepths[s.Rank()] = 0;
int currDepth = 0;
Timer fullTimer;
std::cout.setf( std::ios::fixed, std:: ios::floatfield ); // floatfield set to fixed
std::cout.precision(2);
while (seenStates != s.GetMaxRank())
{
Timer roundTimer;
for (int x = 0; x < s.GetMaxRank(); x++)
{
if (stateDepths[x] == currDepth)
{
s.Unrank(x);
s.GetMoves(moves);
while (moves.IsEmpty() == false)
{
s.ApplyMove(moves.PeekFront());
uint32_t rank = s.Rank();
s.UndoMove(moves.PeekFront());
moves.RemoveFront();
if (stateDepths[rank] == 255)
{
stateDepths[rank] = currDepth+1;
seenStates++;
}
}
}
}
std::cout << roundTimer.GetElapsedTime() << "s elapsed. ";
std::cout << "Depth " << currDepth;
std::cout << " complete. " << seenStates << " of " << s.GetMaxRank();
std::cout << " total states seen.\n";
currDepth++;
}
std::cout << fullTimer.EndTimer() << "s elapsed\n";
delete [] stateDepths;
}
示例11: display_func
static void display_func ( void )
{
fps_time += timer.GetElapsedTime();
rot_time += timer.GetElapsedTime();
timer.Reset();
frames++;
if(fps_time >= 10.0 && rate)
{
cout<<"Framerate:"<<(frames/fps_time)<<endl;
frames = 0;
fps_time = 0;
}
pre_display ();
if ( dvel==0 ) draw_velocity ();
else if ( dvel==1 ) draw_density ();
else if ( dvel==2 ) draw_points ();
else if ( dvel==3 ) draw_particles ();
post_display ();
}
示例12: runProblemSet3
void runProblemSet3(char *scenario)
{
printf("Loading scenario %s\n", scenario);
ScenarioLoader sl(scenario);
printf("Loading map %s\n", sl.GetNthExperiment(0).GetMapName());
Map *map = new Map(sl.GetNthExperiment(0).GetMapName());
map->Scale(sl.GetNthExperiment(0).GetXScale(),
sl.GetNthExperiment(0).GetYScale());
PEAStar<xyLoc, tDirection, MapEnvironment> pea;
TemplateAStar<xyLoc, tDirection, MapEnvironment> astar;
std::vector<xyLoc> thePath;
MapEnvironment ma(map);
ma.SetFourConnected();
for (int x = 0; x < sl.GetNumExperiments(); x++)
{
if (sl.GetNthExperiment(x).GetBucket() != 127)
continue;
xyLoc from, to;
printf("%d\t", sl.GetNthExperiment(x).GetBucket());
from.x = sl.GetNthExperiment(x).GetStartX();
from.y = sl.GetNthExperiment(x).GetStartY();
to.x = sl.GetNthExperiment(x).GetGoalX();
to.y = sl.GetNthExperiment(x).GetGoalY();
Timer t;
t.StartTimer();
pea.GetPath(&ma, from, to, thePath);
t.EndTimer();
printf("pea\t%ld\t%1.6f\t%llu\t%u", thePath.size(), t.GetElapsedTime(), pea.GetNodesExpanded(), pea.GetNumOpenItems());
t.StartTimer();
astar.GetPath(&ma, from, to, thePath);
t.EndTimer();
printf("\tastar\t%ld\t%1.6f\t%llu\t%u\n", thePath.size(), t.GetElapsedTime(), astar.GetNodesExpanded(), astar.GetNumOpenItems());
}
exit(0);
}
示例13: myKey
/*******************************************************************************
Function that gets called for any keypresses.
*******************************************************************************/
void myKey(unsigned char key, int x, int y)
{
float time;
const double speed = 1.0;
switch (key)
{
case 'q':
case 27:
exit(0);
case 's':
g_frameSaver.DumpPPM(g_width,g_height);
break;
case 'x':
addRandomFoodParticle( 100, &World, &Space );
animator.scanForFood( animator.foodParticles.back() );
break;
case 'r':
resetArcball();
break;
case '1':
animator.active = !animator.active;
break;
case 'a':
g_animate = 1 - g_animate;
//Reset the timer to point to the current time.
time = g_timer.GetElapsedTime();
g_timer.Reset();
break;
case '0':
//Reset your object.
break ;
case 'm':
if( g_recording == 1 )
{
std::cout << "Frame recording disabled." << std::endl;
g_recording = 0;
}
else
{
std::cout << "Frame recording enabled." << std::endl;
g_recording = 1 ;
}
g_frameSaver.Toggle();
break ;
case 'h':
case '?':
GDrawing::plotInstructions();
break;
}
glutPostRedisplay();
}
示例14: idleCB
void idleCB(void)
{
if( Animate == 1 )
{
// TM.Reset() ; // commenting out this will make the time run from 0
// leaving 'Time' counts the time interval between successive calls to idleCB
if( Recording == 0 )
TIME = TM.GetElapsedTime() ;
else
TIME += 0.033 ; // save at 30 frames per second.
printf("TIME %f\n", TIME) ;
glutPostRedisplay() ;
}
}
示例15: CreateSomeFiles_And_ListTheFiles
void CreateSomeFiles_And_ListTheFiles(size_t fileNum, size_t loopCount, ApiStatistics* pStatistics)
{
DEF_TESTLOG_T("CreateSomeFiles_And_ListTheFiles, ");
wstring dirpath(GetTestFileName(L"filelisting"));
// Create files
vector<wstring> vCreateFiles;
TouchManyFiles(log, fileNum, GetWidTestBasePath() + L"\\" + dirpath, vCreateFiles, false);
WaitUntilStartTime();
// List files
for(size_t i = 0; i < loopCount; ++i)
{
Timer t;
ListFiles(log, GetWidTestBasePath() + L"\\" + dirpath);
double d = t.GetElapsedTime();
if(pStatistics)
{
pStatistics->InsertData(d);
}
if(IsTimeToEnd())
break;
}
// Delete files
for(size_t i = 0; i < vCreateFiles.size(); ++i)
{
BOOL fOk = uDeleteFile((GetWidTestBasePath() + L"\\" + dirpath + L"\\" + vCreateFiles[i]).c_str());
if(!fOk)
{
log.GetStream(TestLog::MT_ERROR) << L"FindNextFile error. Error is " << GetLastErrorStr() << std::endl;
break;
}
}
uRemoveDirectory((GetWidTestBasePath() + L"\\" + dirpath).c_str());
PrintStatistics(L"CreateSomeFiles_And_ListTheFiles", pStatistics);
log.Ok();
}