Improved profiling: specifying a negative number (--profile=-2)
indicates the number of laps to measure, at the end a summary is printed. No collectables/attachments are done (can easily be activated again), to allow focusing on AI drive performance. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1507 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
7b51fc9d6e
commit
f7ab0ed91f
@ -28,6 +28,7 @@
|
||||
#include "world.hpp"
|
||||
#include "sound_manager.hpp"
|
||||
#include "stk_config.hpp"
|
||||
#include "user_config.hpp"
|
||||
|
||||
Attachment::Attachment(Kart* _kart)
|
||||
{
|
||||
@ -64,6 +65,7 @@ void Attachment::set(attachmentType _type, float time, Kart *current_kart)
|
||||
// -----------------------------------------------------------------------------
|
||||
void Attachment::hitGreenHerring()
|
||||
{
|
||||
if(user_config->m_profile) return;
|
||||
int random_attachment;
|
||||
float leftover_time = 0.0f;
|
||||
switch(getType()) // If there already is an attachment, make it worse :)
|
||||
|
@ -175,7 +175,8 @@ void Collectable::hitRedHerring(int n)
|
||||
newC = (CollectableType)(rand()%(COLLECT_MAX - 1 - nIgnore) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
{ // for now: no collectables when profiling
|
||||
return;
|
||||
// No random effects when profiling!
|
||||
static int simpleCounter=-1;
|
||||
simpleCounter++;
|
||||
|
@ -81,6 +81,7 @@ void GameManager::run()
|
||||
{
|
||||
music_on = false;
|
||||
float dt = (m_curr_time - m_prev_time ) * 0.001f;
|
||||
if(user_config->m_profile) dt=1.0f/60.0f;
|
||||
// In the first call dt might be large (includes loading time),
|
||||
// which can cause the camera to significantly tilt
|
||||
scene->draw(world->getPhase()==World::SETUP_PHASE ? 0.0f : dt);
|
||||
@ -88,7 +89,7 @@ void GameManager::run()
|
||||
{
|
||||
world->update(dt);
|
||||
|
||||
if(user_config->m_profile)
|
||||
if(user_config->m_profile>0)
|
||||
{
|
||||
m_frame_count++;
|
||||
if (world->getTime()>user_config->m_profile)
|
||||
|
17
src/main.cpp
17
src/main.cpp
@ -100,6 +100,7 @@ void cmdLineHelp (char* invocation)
|
||||
// should not be used by unaware users:
|
||||
// " --profile Enable automatic driven profile mode for 20 seconds\n"
|
||||
// " --profile=n Enable automatic driven profile mode for n seconds\n"
|
||||
// " if n<0 --> (-n) = number of laps to drive
|
||||
// " --history Replay history file 'history.dat'\n"
|
||||
" --log=terminal Write messages to screen\n"
|
||||
" --log=file Write messages/warning to log files stdout.log/stderr.log\n"
|
||||
@ -328,6 +329,16 @@ int handleCmdLine(int argc, char **argv)
|
||||
}else if( sscanf(argv[i], "--profile=%d", &n)==1)
|
||||
{
|
||||
user_config->m_profile=n;
|
||||
if(n<0)
|
||||
{
|
||||
fprintf(stdout,"Profiling %d laps\n",-n);
|
||||
race_manager->setNumLaps(-n);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Profiling: %d seconds.\n",user_config->m_profile);
|
||||
race_manager->setNumLaps (999999); // profile end depends on time
|
||||
}
|
||||
}
|
||||
else if( !strcmp(argv[i], "--profile") )
|
||||
{
|
||||
@ -350,7 +361,6 @@ int handleCmdLine(int argc, char **argv)
|
||||
} // for i <argc
|
||||
if(user_config->m_profile)
|
||||
{
|
||||
printf("Profiling: %d seconds.\n",user_config->m_profile);
|
||||
user_config->setSFX(UserConfig::UC_DISABLE); // Disable sound effects
|
||||
user_config->setMusic(UserConfig::UC_DISABLE);// and music when profiling
|
||||
}
|
||||
@ -486,7 +496,7 @@ int main(int argc, char *argv[] )
|
||||
race_manager->start();
|
||||
}
|
||||
}
|
||||
else // profilie
|
||||
else // profile
|
||||
{
|
||||
|
||||
// Profiling
|
||||
@ -494,8 +504,7 @@ int main(int argc, char *argv[] )
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setPlayerKart(0, kart_properties_manager->getKart("tuxkart")->getIdent());
|
||||
race_manager->setRaceMode (RaceSetup::RM_QUICK_RACE);
|
||||
race_manager->setDifficulty(RD_MEDIUM);
|
||||
race_manager->setNumLaps (999999); // profile end depends on time
|
||||
race_manager->setDifficulty(RD_HARD);
|
||||
race_manager->start();
|
||||
}
|
||||
game_manager->run();
|
||||
|
@ -139,6 +139,8 @@ void Scene::draw(float dt)
|
||||
|
||||
if(!user_config->m_bullet_debug)
|
||||
{
|
||||
// Use this for faster profiling by disabling drawing the scene graph
|
||||
//if(!user_config->m_profile)ssgCullAndDraw ( m_scenegraph );
|
||||
ssgCullAndDraw ( m_scenegraph );
|
||||
}
|
||||
else
|
||||
|
@ -106,6 +106,12 @@ World::World(const RaceSetup& raceSetup_) : m_race_setup(raceSetup_)
|
||||
// In profile mode, load only the old kart
|
||||
newkart = new DefaultRobot (kart_properties_manager->getKart("tuxkart"), pos,
|
||||
init_pos);
|
||||
// Create a camera for the last kart (since this way more of the
|
||||
// karts can be seen.
|
||||
if((i+1)==m_race_setup.m_karts.end())
|
||||
{
|
||||
scene->createCamera(m_race_setup.getNumPlayers(), playerIndex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -488,12 +494,29 @@ void World::updateRaceStatus(float dt)
|
||||
if(race_manager->getFinishedKarts() >= m_race_setup.getNumKarts() )
|
||||
{
|
||||
m_phase = FINISH_PHASE;
|
||||
if(user_config->m_profile<0) // profiling number of laps -> print stats
|
||||
{
|
||||
float min_t=999999.9, max_t=0.0, av_t=0.0;
|
||||
for ( Karts::size_type i = 0; i < m_kart.size(); ++i)
|
||||
{
|
||||
max_t = std::max(max_t, m_kart[i]->getFinishTime());
|
||||
min_t = std::min(min_t, m_kart[i]->getFinishTime());
|
||||
av_t += m_kart[i]->getFinishTime();
|
||||
printf("%s start %d end %d time %f\n",
|
||||
m_kart[i]->getName().c_str(),(int)i,
|
||||
m_kart[i]->getPosition(),
|
||||
m_kart[i]->getFinishTime());
|
||||
}
|
||||
printf("min %f max %f av %f\n",min_t, max_t, av_t/m_kart.size());
|
||||
std::exit(-2);
|
||||
}
|
||||
}
|
||||
|
||||
// 2) All player karts are finished --> wait some
|
||||
// time for AI karts to arrive before finishing
|
||||
// ===============================================
|
||||
else if(race_manager->allPlayerFinished() && m_phase == RACE_PHASE)
|
||||
else if(race_manager->allPlayerFinished() && m_phase == RACE_PHASE &&
|
||||
!user_config->m_profile)
|
||||
{
|
||||
m_phase = DELAY_FINISH_PHASE;
|
||||
m_finish_delay_start_time = m_clock;
|
||||
@ -502,7 +525,8 @@ void World::updateRaceStatus(float dt)
|
||||
// 3) If the 'wait for AI' time is over, estimate arrival times & finish
|
||||
// =====================================================================
|
||||
else if(m_phase==DELAY_FINISH_PHASE &&
|
||||
m_clock-m_finish_delay_start_time>TIME_DELAY_TILL_FINISH)
|
||||
m_clock-m_finish_delay_start_time>TIME_DELAY_TILL_FINISH &&
|
||||
!user_config->m_profile)
|
||||
{
|
||||
m_phase = FINISH_PHASE;
|
||||
for ( Karts::size_type i = 0; i < m_kart.size(); ++i)
|
||||
|
Loading…
x
Reference in New Issue
Block a user