本文整理汇总了C++中Stopwatch::GetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Stopwatch::GetValue方法的具体用法?C++ Stopwatch::GetValue怎么用?C++ Stopwatch::GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stopwatch
的用法示例。
在下文中一共展示了Stopwatch::GetValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Launch
bool BenchmarkMenu::Launch(BenchItem *b)
{
if (!b)
return false;
bool ok = false;
float score = 0.0f;
const char *fmt = "";
switch (b->type) {
case BENCH_MENU:
{
Stopwatch clock;
delete (new OptionMenu());
score = 1000.0f / clock.GetValue();
fmt = "%.3f";
ok = true;
break;
}
case BENCH_GRAPHICS:
{
graph->UnsetResults();
// Backup and set playing teams
std::vector<Team*> list_bak = GetTeamsList().GetPlayingList();
std::list<uint> sel; sel.push_back(1); sel.push_back(2);
GetTeamsList().ChangeSelection(sel);
// Backup and set team configuration - make it quick ;)
std::vector<Team*>& list = GetTeamsList().GetPlayingList();
for (uint i=0; i<list.size(); i++) {
printf("Setting %s\n", list[i]->GetName().c_str());
list[i]->SetPlayerName("CPU");
list[i]->SetNbCharacters(10);
list[i]->SetAIName(STRONG_AI_NAME);
list[i]->SetGroup(i);
}
// Backup and set game mode
Config *cfg = Config::GetInstance();
std::string game_mode = cfg->GetGameMode();
cfg->SetGameMode("benchmark");
GameMode::GetInstance()->Load();
// Backup and set some config options
uint wind_particles = cfg->GetWindParticlesPercentage(); cfg->SetWindParticlesPercentage(100);
bool display_energy = cfg->GetDisplayEnergyCharacter(); cfg->SetDisplayEnergyCharacter(true);
bool display_multisky = cfg->GetDisplayMultiLayerSky(); cfg->SetDisplayMultiLayerSky(false);
// Mute all sounds
JukeBox *jbox = JukeBox::GetInstance();
bool music = cfg->GetSoundMusic(); jbox->ActiveMusic(false);
bool sfx = cfg->GetSoundEffects(); cfg->SetSoundEffects(false);
// Backup and set default map - should I save the config?
std::string map_name = cfg->GetMapName();
MapsList *maps = MapsList::GetInstance();
int map_id_bak = maps->GetActiveMapIndex(); maps->SelectMapByName("banquise");
if (!maps->lst[maps->GetActiveMapIndex()]->LoadBasicInfo()) {
fmt = "Error!";
break;
}
// Set max FPS
Video *video = AppWarmux::GetInstance()->video;
int fps = video->GetMaxFps(); video->SetMaxFps(60);
// Set seeds - we'll set random ones afterwards
RandomLocal().SetSeed(0xABADCAFE);
RandomSync().SetSeed(0xABADCAFE);
// All set, run the game!
float num = Game::UpdateGameRules()->Start(true);
if (num) {
GraphCanvas::Result res;
res.list = Game::GetInstance()->GetBenchResults();
GraphCanvas::FindMax(res);
float time = res.xmax - res.list[0].first;
score = (num * video->window.GetWidth()*video->window.GetHeight())
/ (1000.0f * time);
fmt = "%.0f";
res.item = NULL;
res.color = primary_red_color;
graph->AddResult(res);
} else {
fmt = "Aborted";
}
graph->NeedRedrawing();
// Restore all!
video->SetMaxFps(fps);
jbox->ActiveMusic(music);
cfg->SetSoundEffects(sfx);
maps->SelectMapByIndex(map_id_bak);
cfg->SetMapName(map_name);
cfg->SetDisplayMultiLayerSky(display_multisky);
cfg->SetDisplayEnergyCharacter(display_energy);
cfg->SetWindParticlesPercentage(wind_particles);
//.........这里部分代码省略.........