David Megginson writes:

 > I'm not sure, but I'm going to try profiling a much longer run.

I did another run, with a flight of over one hour on autopilot.
Cumulatively, ssgEntity::cull_test and ssgBranch::cull use nearly 20%
of CPU time -- that's OK, as long as the framerate improvements
justify the work.

I can see room for some easy plib optimizations.  For example, the
program spent 2.95% of its time in ssgVtxTable::getNumVertices, 1.91%
of its time in ssgVtxTable::getNumColours and 1.8% of its time in
ssgVtxTable::getNumTexCoords.  All of these might be able to be
optimized to cache the result, rather than counting through the arrays
each time (if they do that currently), and it looks like the saving
could be significant.

On our side, the biggest hog is FGHitList::IntersectBranch, with 3.96%
of CPU time.  I assume that's calculating the ground elevation, but
any optimizations might be helpful, if people can think of one.  The
next biggest fgfs hog is in my own code, FGInstrumentLayer::transform,
with 2.62% of CPU time.  That's the routine that does all the work of
moving needles, etc. on the 2D instrument panel.  Norm Vine sent me
some patches a while back, and I'll have to look at those again and
see if any of them can improve performance.  FGLayeredInstrument::draw
is also hogging a lot of time (1.3%).

The good news is that the JSBSim matrix support isn't showing up on
the radar screen any more.

Here are all of the calls that used more than 0.1% of CPU time
themselves (excluding time spent in sub-calls):

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  us/call  us/call  name    
 10.92    111.07   111.07                             ssgEntity::cull_test(sgFrustum*, 
float (*) [4], int)
  8.83    200.80    89.73                             ssgBranch::cull(sgFrustum*, 
float (*) [4], int)
  7.17    273.74    72.94                             ssgVtxTable::draw_geometry()
  3.96    314.05    40.31   194750   206.98   324.01  
FGHitList::IntersectBranch(ssgBranch*, double (*) [4], double*, double*)
  3.54    350.09    36.04                             sgFrustum::contains(sgSphere 
const*) const
  2.95    380.08    29.99                             ssgVtxTable::getNumVertices()
  2.62    406.75    26.67 35976774     0.74     0.95  FGInstrumentLayer::transform() 
const
  2.60    433.15    26.40                             sgXformPnt3(float*, float 
const*, float[4] const*)
  2.13    454.82    21.67                             ssgSimpleState::apply()
  2.04    475.56    20.74                             
slEnvelope::applyToVolume(unsigned char*, unsigned char*, int, int)
  1.91    495.02    19.46                             ssgVtxTable::getNumColours()
  1.80    513.36    18.34                             ssgVtxTable::getNumTexCoords()
  1.74    531.06    17.70 153985261     0.11     0.11  
sgdClosestPointToLineDistSquared(double const*, double const*, double const*)
  1.38    545.05    13.99                             ssgLeaf::cull(sgFrustum*, float 
(*) [4], int)
  1.30    558.30    13.25  5401928     2.45    13.85  FGLayeredInstrument::draw()
  1.30    571.49    13.19 14370084     0.92     1.04  
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
const, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> 
> const, SGPropertyNode*>, std::_Select1st<std::pair<std::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const, SGPropertyNode*> >, 
std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
const>, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, 
std::allocator<char> > const, SGPropertyNode*> > 
>::lower_bound(std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
const&)
  1.29    584.62    13.13 20530050     0.64     0.67  
find_child(std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
const&, int, std::vector<SGPropertyNode*, std::allocator<SGPropertyNode*> >)
  1.06    595.35    10.73  4561755     2.35     2.35  
FGTileEntry::prep_ssg_node(Point3D const&, float)
  0.87    604.22     8.87   201172    44.09    44.54  calc_magvar(double, double, 
double, long, double*)
  0.87    613.03     8.81 31254012     0.28     1.33  FGTexturedLayer::draw()
  0.80    621.12     8.09                             sgdXformPnt3(double*, double 
const*, double[4] const*)
  0.74    628.61     7.49                             
slEnvelope::applyToPitch(unsigned char*, slPlayer*, int, int, int)
  0.64    635.16     6.55                             ssgBranch::recalcBSphere()
  0.60    641.24     6.08 34749950     0.17     0.17  
std::_Rb_tree_base_iterator::_M_increment()
  0.60    647.32     6.08                             fntTexFont::low_putch(float*, 
float, float, char)
  0.59    653.27     5.95                             slPlayer::read(int, unsigned 
char*, int)
  0.56    659.01     5.74 77211892     0.07     0.25  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::reserve(unsigned)
  0.54    664.54     5.53 141944439     0.04     0.07  
std::__default_alloc_template<(bool)1, (int)0>::allocate(unsigned)
  0.50    669.60     5.06                             ssgLeaf::preDraw()
  0.47    674.40     4.80 19650364     0.24     0.30  SGPropertyNode::getFloatValue() 
const
  0.45    678.99     4.59 64177291     0.07     0.10  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> 
>::basic_string[in-charge](std::basic_string<char, std::char_traits<char>, 
std::allocator<char> > const&)
  0.44    683.50     4.51                             sgdMakeNormal(double*, double 
const*, double const*, double const*)
  0.44    687.96     4.46                             ssgStateSelector::isTranslucent()
  0.44    692.40     4.44   194751    22.80    64.81  
FGMaterialLib::load_next_deferred()
  0.43    696.78     4.38                             ssgVtxTable::getNumNormals()
  0.42    701.07     4.29                             
ssgTransform::setTransform(float*)
  0.42    705.30     4.23                             ssgVtxTable::draw()
  0.41    709.43     4.13 135903072     0.03     0.04  
std::__default_alloc_template<(bool)1, (int)0>::deallocate(void*, unsigned)
  0.39    713.43     4.00 292342689     0.01     0.01  
std::__default_alloc_template<(bool)1, (int)0>::_Lock::~_Lock [in-charge]()
  0.39    717.42     3.99 14369733     0.28     2.64  
parse_name(std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
const&, int&)
  0.39    721.38     3.96 77206095     0.05     0.10  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::replace(std::__normal_iterator<char*, 
std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, 
std::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, 
std::allocator<char> > >, unsigned, char)
  0.39    725.33     3.95   810555     4.87     4.87  geo_inverse_wgs_84(double, 
double, double, double, double, double*, double*, double*)
  0.39    729.28     3.95                             sgSphere::extend(sgSphere const*)
  0.37    733.09     3.81 66104380     0.06     0.06  FGState::GetParameter(eParam)
  0.36    736.72     3.63  6161354     0.59     9.41  
parse_path(std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
const&, std::vector<PathComponent, std::allocator<PathComponent> >&)
  0.35    740.29     3.57 80311620     0.04     0.05  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned, unsigned, unsigned)
  0.34    743.75     3.46   194751    17.77   612.05  fgRenderFrame()
  0.33    747.15     3.40 11786051     0.29     0.51  FGCoefficient::Value()
  0.32    750.42     3.27  1363257     2.40     2.64  
CelestialBody::updatePosition(double, Star*)
  0.32    753.67     3.25 95366653     0.03     0.09  FGConditional::test() const
  0.32    756.91     3.24 77206095     0.04     0.39  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::append(unsigned, char)
  0.31    760.10     3.19                             sgMultMat4(float (*) [4], float 
() [4] const*, float () [4] const*)
  0.31    763.22     3.12                             ssgEntity::dirtyBSphere()
  0.30    766.32     3.10  6149244     0.50     0.50  FGTable::GetValue(double)
  0.30    769.35     3.03   512323     5.91    27.86  FGAutopilot::run()
  0.30    772.38     3.03   192926    15.71   408.32  FGPanel::update(float, float, 
float, float)
  0.30    775.39     3.01                             
ssgStateSelector::getCurrentStep()
  0.29    778.34     2.95                             
ssgRangeSelector::cull(sgFrustum*, float (*) [4], int)
  0.29    781.28     2.94 91582787     0.03     0.12  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::_Rep::_M_clone(std::allocator<char> 
const&, unsigned)
  0.29    784.22     2.94   512324     5.74   167.79  FGJSBsim::copy_from_JSBsim()
  0.29    787.14     2.92  7504881     0.39     0.54  SGPropertyNode::getBoolValue() 
const
  0.29    790.04     2.90 30186274     0.10     0.10  FGNewMat::load_texture()
  0.28    792.86     2.82 30096456     0.09     0.09  FGCroppedTexture::getTexture()
  0.28    795.67     2.81 121093433     0.02     0.07  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::_Rep::_M_destroy(std::allocator<char> 
const&)
  0.27    798.41     2.74   194750    14.07    14.07  
FGInterface::operator=(FGInterface const&)
  0.26    801.10     2.69 104824117     0.03     0.03  FGColumnVector3::Debug(int)
  0.26    803.77     2.67 121128869     0.02     0.09  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::_Rep::_S_create(unsigned, 
std::allocator<char> const&)
  0.26    806.42     2.65 63903158     0.04     0.04  std::basic_ostream<char, 
std::char_traits<char> >::sentry::sentry[in-charge](std::basic_ostream<char, 
std::char_traits<char> >&)
  0.25    808.97     2.55 14369581     0.18     0.59  std::vector<PathComponent, 
std::allocator<PathComponent> >::_M_insert_aux(std::__normal_iterator<PathComponent*, 
std::vector<PathComponent, std::allocator<PathComponent> > >, PathComponent const&)
  0.24    811.46     2.49                             ssgState::preApply()
  0.24    813.92     2.46   942321     2.61     5.40  
FGHitList::IntersectLeaf(ssgLeaf*, double (*) [4], double*, double*)
  0.24    816.34     2.42 52529759     0.05     0.05  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::compare(char const*) const
  0.22    818.59     2.25                             slEnvelope::getStepDelta(float*, 
float*)
  0.22    820.82     2.23   512324     4.35    46.61  FGJSBsim::copy_to_JSBsim()
  0.21    823.00     2.18   512437     4.25     9.22  FGAerodynamics::Run()
  0.21    825.15     2.15 16397984     0.13     0.75  FGCoefficient::TotalValue()
  0.21    827.29     2.14   387889     5.52    10.75  FGViewerRPH::update()
  0.21    829.40     2.11   194751    10.83    30.18  FGRadioStack::update(int)
  0.20    831.45     2.05                             ssgStateSelector::apply()
  0.20    833.48     2.03                             ssgTransform::cull(sgFrustum*, 
float (*) [4], int)
  0.20    835.49     2.01 42559504     0.05     0.10  char* std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::_S_construct<char const*>(char const*, 
char const*, std::allocator<char> const&, std::forward_iterator_tag)
  0.20    837.49     2.00 11403343     0.18     0.19  SGPropertyNode::getDoubleValue() 
const
  0.20    839.48     1.99 142092955     0.01     0.01  
std::__default_alloc_template<(bool)1, (int)0>::_Lock::_Lock[in-charge]()
  0.20    841.47     1.99 96555001     0.02     0.02  unsigned const& 
std::min<unsigned>(unsigned const&, unsigned const&)
  0.19    843.43     1.96                             slSamplePlayer::low_read(int, 
unsigned char*)
  0.19    845.39     1.96                             ssgSimpleState::getTexture()
  0.19    847.34     1.95 42548401     0.05     0.15  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::basic_string[in-charge](char const*, 
std::allocator<char> const&)
  0.19    849.25     1.91 10759526     0.18     0.20  
SGPropertyNode::setDoubleValue(double)
  0.19    851.16     1.91                             ssgEntity::preTravTests(int*, 
int)
  0.18    852.96     1.80   707142     2.55     2.55  sgGeocToGeod(double, double, 
double*, double*, double*)
  0.17    854.70     1.74 27143979     0.06     0.10  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::_Rep::_M_dispose(std::allocator<char> 
const&)
  0.17    856.44     1.74                             ssgSimpleState::force()
  0.17    858.14     1.70  2142261     0.79     2.58  FGSound::update(int)
  0.17    859.83     1.69   194751     8.68  2184.12  fgMainLoop()
  0.17    861.51     1.68  2826290     0.59     0.92  FGSteam::_CatchUp()
  0.16    863.17     1.66  6161354     0.27     2.56  find_node(SGPropertyNode*, 
std::vector<PathComponent, std::allocator<PathComponent> > const&, int, bool)
  0.16    864.77     1.60 14363450     0.11     1.23  
SGPropertyNode::getNode(std::basic_string<char, std::char_traits<char>, 
std::allocator<char> > const&, bool)
  0.15    866.33     1.56   194751     8.01     8.25  MoonPos::updatePosition(double, 
double, double, Star*)
  0.15    867.88     1.55   125778    12.32    12.32  SGSkyDome::repaint(float*, 
float*, double, double)
  0.15    869.42     1.54 123133993     0.01     0.01  
std::allocator<char>::~allocator [in-charge]()
  0.15    870.96     1.54                             ssgSelector::cull(sgFrustum*, 
float (*) [4], int)
  0.15    872.49     1.53 14444038     0.11     0.11  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::assign(std::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)
  0.15    873.98     1.49  1608679     0.93     1.03  
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, 
std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
const, FGSimpleSound*>, std::_Select1st<std::pair<std::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const, FGSimpleSound*> >, 
std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, 
std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, 
std::allocator<char> > const, FGSimpleSound*> > >::find(std::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)
  0.15    875.46     1.48 47830284     0.03     0.03  std::basic_ostream<char, 
std::char_traits<char> >::sentry::~sentry [in-charge]()
  0.15    876.94     1.48  6623608     0.22     0.22  
FGInput::_update_button(FGInput::button&, int, bool)
  0.15    878.42     1.48                             puGroup::draw(int, int)
  0.14    879.89     1.47                             ssgState::isTranslucent()
  0.14    881.33     1.44  9329964     0.15     0.15  sgdPointInTriangle(double*, 
double (*) [3])
  0.14    882.77     1.44   512324     2.81    95.06  FGJSBsim::update_gear()
  0.14    884.20     1.43                             ssgMakeMipMaps(unsigned char*, 
int, int, int)
  0.14    885.61     1.41                             sgSetCoord(sgCoord*, float[4] 
const*)
  0.14    887.01     1.40 20528560     0.07     0.83  
SGPropertyNode::getChild(std::basic_string<char, std::char_traits<char>, 
std::allocator<char> > const&, int, bool)
  0.12    888.25     1.24 31671587     0.04     0.05  
FGColumnVector3::FGColumnVector3[in-charge](FGColumnVector3 const&)
  0.12    889.49     1.24   194812     6.37    17.31  FGInput::_update_joystick()
  0.12    890.70     1.21   194752     6.21   354.70  FGTileMgr::update(double, double)
  0.12    891.89     1.19  9329964     0.13     0.13  sgdIsectInfLinePlane(double*, 
double*, double*, double*)
  0.12    893.07     1.18                             puBox::extend(puBox*)
  0.12    894.24     1.17  3665594     0.32     3.69  FGSwitchLayer::draw()
  0.12    895.41     1.17   194750     6.01   998.70  fgUpdateTimeDepCalcs()
  0.11    896.53     1.12  1155090     0.97     0.97  sgGeodToGeoc(double, double, 
double*, double*)
  0.11    897.63     1.10 123374154     0.01     0.01  std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::_Alloc_hider::~_Alloc_hider 
[in-charge]()
  0.11    898.73     1.10  6223002     0.18     0.20  SGPropertyNode::getStringValue() 
const
  0.11    899.81     1.08                             ssgState::preDraw()
  0.11    900.88     1.07 27698701     0.04     0.04  std::basic_ostream<char, 
std::char_traits<char> >& std::operator<< <std::char_traits<char> 
>(std::basic_ostream<char, std::char_traits<char> >&, char const*)
  0.11    901.95     1.07  1929260     0.55     2.60  FGTextLayer::draw()
  0.11    903.02     1.07   512437     2.09     7.59  FGFCS::Run()
  0.10    904.07     1.05  2700964     0.39     1.56  doComparison(SGPropertyNode 
const*, SGPropertyNode const*)
  0.10    905.09     1.02   389624     2.62     3.21  SGCloudLayer::reposition(float*, 
float*, double, double, double)
  0.10    906.11     1.02                             
ssgSimpleState::setTexture(ssgTexture*)
  0.10    907.11     1.00                             
ssgSimpleState::getTextureHandle()
  0.10    908.10     0.99 14369733     0.07     0.16  PathComponent::~PathComponent 
[in-charge]()
  0.10    909.09     0.99                             ssgVtxTable::getVertex(int)
  0.10    910.07     0.98 28739162     0.03     0.07  
std::__normal_iterator<PathComponent*, std::vector<PathComponent, 
std::allocator<PathComponent> > > 
std::__uninitialized_copy_aux<std::__normal_iterator<PathComponent*, 
std::vector<PathComponent, std::allocator<PathComponent> > >, 
std::__normal_iterator<PathComponent*, std::vector<PathComponent, 
std::allocator<PathComponent> > > >(std::__normal_iterator<PathComponent*, 
std::vector<PathComponent, std::allocator<PathComponent> > >, 
std::__normal_iterator<PathComponent*, std::vector<PathComponent, 
std::allocator<PathComponent> > >, std::__normal_iterator<PathComponent*, 
std::vector<PathComponent, std::allocator<PathComponent> > >, _Bool<(bool)0>)
  0.10    911.05     0.98  4705533     0.21     0.40  
FGMatrix33::operator*(FGColumnVector3 const&)


All the best,


David

-- 
David Megginson
[EMAIL PROTECTED]


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to