Ok, without citycars, game and pak load automatically, all messages autoclose.
old code:
minimized total 255,9s second 259,3s
memory between 39400kB and 41800kB
P****engers 33%
Post 21%
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
11.43 29.25 29.25 1502425 0.00 0.00 haltestelle_t::suche_route(ware_t&, koord*)
5.63 43.66 14.40 18463 0.00 0.00 karte_t::sync_step(long, bool, bool)
4.46 55.08 11.42 1584337647 0.00 0.00 quickstone_tpl<haltestelle_t>::is_bound() const
3.97 65.23 10.15 15162 0.00 0.00 route_t::find_route(karte_t*, koord3d, fahrer_t*, unsigned int, unsigned char, unsigned int)
3.29 73.66 8.43 6784023 0.00 0.00 display_img_nc(short, short, short, unsigned short const*)
3.13 81.66 8.00 1601035112 0.00 0.00 slist_iterator_tpl<warenziel_t>::next()
2.70 88.56 6.90 2223387965 0.00 0.00 quickstone_tpl<haltestelle_t>::quickstone_tpl(quickstone_tpl<haltestelle_t> const&)
2.35 94.56 6.00 1819776320 0.00 0.00 quickstone_tpl<haltestelle_t>::operator->() const
2.20 100.19 5.63 1680132 0.00 0.00 recode_img_src_target_color(short, unsigned short*, unsigned short*)
1.93 105.13 4.94 1769667949 0.00 0.00 vector_tpl<route_t::ANode*>::operator[](unsigned int)
1.84 109.83 4.70 1537297492 0.00 0.00 slist_iterator_tpl<warenziel_t>::get_current() const
1.79 114.41 4.58 1531036154 0.00 0.00 warenziel_t::gib_zielhalt() const
1.49 118.22 3.82 1706583 0.00 0.00 haltestelle_t::hole_ab(ware_besch_t const*, unsigned int, fahrplan_t*)
1.42 121.86 3.64 1996273 0.00 0.00 hashtable_tpl<sync_steppable*, sync_steppable*, ptrhash_tpl<sync_steppable*> >::put(sync_steppable*, sync_steppable*)
1.35 125.33 3.46 32342391 0.00 0.00 convoi_t::sync_step(long)
1.35 128.78 3.45 1599828592 0.00 0.00 einstellungen_t::gib_max_hops() const
1.35 132.23 3.45 107987406 0.00 0.00 planquadrat_t::gib_boden_in_hoehe(short) const
1.23 135.38 3.15 1603078938 0.00 0.00 karte_t::gib_einstellungen() const
1.18 138.41 3.03 163004359 0.00 0.00 ding_t::get_flag(ding_t::flag_values) const
1.15 141.35 2.94 208523962 0.00 0.00 karte_t::ist_in_kartengrenzen(short, short) const
1.14 144.26 2.91 203551949 0.00 0.00 grund_t::gib_hoehe() const
1.12 147.13 2.87 1783291686 0.00 0.00 vector_tpl<route_t::ANode*>::get_count() const
1.12 149.99 2.86 19017002 0.00 0.00 convoi_t::calc_acceleration(long)
1.07 152.71 2.73 145805716 0.00 0.00 vehikel_basis_t::fahre_basis(unsigned int)
1.02 155.32 2.61 112422439 0.00 0.00 dingliste_t::bei(unsigned char) const
1.00 157.88 2.56 54977847 0.00 0.00 quickstone_tpl<simline_t>::is_bound() const
and second:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
12.59 32.64 32.64 1489845 0.00 0.00 haltestelle_t::suche_route(ware_t&, koord*)
5.37 46.56 13.92 18326 0.00 0.00 karte_t::sync_step(long, bool, bool)
4.16 57.35 10.79 1589167260 0.00 0.00 quickstone_tpl<haltestelle_t>::is_bound() const
3.89 67.44 10.09 13715 0.00 0.00 route_t::find_route(karte_t*, koord3d, fahrer_t*, unsigned int, unsigned char, unsigned int)
3.29 75.97 8.53 1606343252 0.00 0.00 slist_iterator_tpl<warenziel_t>::next()
2.94 83.58 7.61 6650334 0.00 0.00 display_img_nc(short, short, short, unsigned short const*)
2.90 91.11 7.53 2229764815 0.00 0.00 quickstone_tpl<haltestelle_t>::quickstone_tpl(quickstone_tpl<haltestelle_t> const&)
2.33 97.15 6.04 1825290743 0.00 0.00 quickstone_tpl<haltestelle_t>::operator->() const
2.05 102.47 5.32 1646269 0.00 0.00 recode_img_src_target_color(short, unsigned short*, unsigned short*)
2.00 107.66 5.19 1542396091 0.00 0.00 slist_iterator_tpl<warenziel_t>::get_current() const
1.84 112.43 4.77 1612835814 0.00 0.00 vector_tpl<route_t::ANode*>::operator[](unsigned int)
1.84 117.19 4.76 1536236002 0.00 0.00 warenziel_t::gib_zielhalt() const
1.70 121.59 4.40 2001100 0.00 0.00 hashtable_tpl<sync_steppable*, sync_steppable*, ptrhash_tpl<sync_steppable*> >::put(sync_steppable*, sync_steppable*)
1.61 125.76 4.17 1605136600 0.00 0.00 einstellungen_t::gib_max_hops() const
1.51 129.67 3.91 107879945 0.00 0.00 planquadrat_t::gib_boden_in_hoehe(short) const
1.40 133.29 3.62 1705248 0.00 0.00 haltestelle_t::hole_ab(ware_besch_t const*, unsigned int, fahrplan_t*)
1.37 136.85 3.56 19113064 0.00 0.00 convoi_t::calc_acceleration(long)
1.35 140.36 3.51 1608378372 0.00 0.00 karte_t::gib_einstellungen() const
1.22 143.54 3.17 32350320 0.00 0.00 convoi_t::sync_step(long)
1.12 146.44 2.90 202627304 0.00 0.00 grund_t::gib_hoehe() const
1.06 149.19 2.75 163018130 0.00 0.00 ding_t::get_flag(ding_t::flag_values) const
1.05 151.91 2.72 207872148 0.00 0.00 karte_t::ist_in_kartengrenzen(short, short) const
your code:
total 267,2s
memory between 40500kB and 46500kB
P****engers 52%
Post 21%
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
16.64 44.46 44.46 1482615 0.00 0.00 haltestelle_t::suche_route(ware_t&, koord*)
5.87 60.14 15.68 18155 0.00 0.00 karte_t::sync_step(long, bool, bool)
5.29 74.26 14.12 3165878648 0.00 0.00 quickstone_tpl<haltestelle_t>::quickstone_tpl(quickstone_tpl<haltestelle_t> const&)
3.51 83.63 9.37 13040 0.00 0.00 route_t::find_route(karte_t*, koord3d, fahrer_t*, unsigned int, unsigned char, unsigned int)
3.39 92.69 9.06 2460099998 0.00 0.00 quickstone_tpl<haltestelle_t>::operator->() const
2.55 99.50 6.80 6273195 0.00 0.00 display_img_nc(short, short, short, unsigned short const*)
2.35 105.78 6.28 2096927630 0.00 0.00 ordered_vector_tpl<quickstone_tpl<haltestelle_t>, unsigned short>::get_by_index(unsigned short) const
2.29 111.89 6.11 1791235 0.00 0.00 haltestelle_t::hole_ab(ware_besch_t const*, unsigned int, fahrplan_t*)
1.95 117.10 5.21 1654897 0.00 0.00 recode_img_src_target_color(short, unsigned short*, unsigned short*)
1.67 121.55 4.45 1589204793 0.00 0.00 vector_tpl<route_t::ANode*>::operator[](unsigned int)
1.66 125.99 4.44 2069764 0.00 0.00 hashtable_tpl<sync_steppable*, sync_steppable*, ptrhash_tpl<sync_steppable*> >::put(sync_steppable*, sync_steppable*)
1.34 129.56 3.57 559439927 0.00 0.00 quickstone_tpl<haltestelle_t>::operator==(quickstone_tpl<haltestelle_t> const&) const
1.29 133.00 3.44 100241111 0.00 0.00 planquadrat_t::gib_boden_in_hoehe(short) const
1.26 136.37 3.38 32889492 0.00 0.00 convoi_t::sync_step(long)
1.17 139.49 3.12 1008054273 0.00 0.00 vector_tpl<ware_t>::operator[](unsigned int)
1.15 142.55 3.06 19154175 0.00 0.00 convoi_t::calc_acceleration(long)
1.08 145.43 2.88 166307945 0.00 0.00 ding_t::get_flag(ding_t::flag_values) const
1.03 148.18 2.75 461906969 0.00 0.00 slist_iterator_tpl<hashtable_tpl<sync_steppable*, sync_steppable*, ptrhash_tpl<sync_steppable*> >::node_t>::next()
1.02 150.90 2.71 149366562 0.00 0.00 vehikel_basis_t::fahre_basis(unsigned int)
my caching code:
total 241,8s
memory between 38200kB and 46000kB
P****engers 33%
Post 21%
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
13.31 32.19 32.19 751021 0.00 0.00 haltestelle_t::suche_route(ware_t&, koord*)
5.87 46.37 14.18 17744 0.00 0.00 karte_t::sync_step(long, bool, bool)
3.21 54.13 7.77 1430432534 0.00 0.00 quickstone_tpl<haltestelle_t>::is_bound() const
2.88 61.09 6.96 6001066 0.00 0.00 display_img_nc(short, short, short, unsigned short const*)
2.77 67.79 6.70 1436250716 0.00 0.00 slist_iterator_tpl<warenziel_t>::next()
2.70 74.31 6.52 2037970909 0.00 0.00 quickstone_tpl<haltestelle_t>::quickstone_tpl(quickstone_tpl<haltestelle_t> const&)
2.66 80.73 6.42 13082 0.00 0.00 route_t::find_route(karte_t*, koord3d, fahrer_t*, unsigned int, unsigned char, unsigned int)
2.09 85.80 5.06 1633681009 0.00 0.00 quickstone_tpl<haltestelle_t>::operator->() const
1.89 90.36 4.57 1984277 0.00 0.00 hashtable_tpl<sync_steppable*, sync_steppable*, ptrhash_tpl<sync_steppable*> >::put(sync_steppable*, sync_steppable*)
1.78 94.67 4.30 1490387 0.00 0.00 recode_img_src_target_color(short, unsigned short*, unsigned short*)
1.69 98.75 4.09 1405342181 0.00 0.00 warenziel_t::gib_zielhalt() const
1.60 102.62 3.87 1715025 0.00 0.00 haltestelle_t::hole_ab(ware_besch_t const*, unsigned int, fahrplan_t*)
1.53 106.31 3.69 107662601 0.00 0.00 planquadrat_t::gib_boden_in_hoehe(short) const
1.51 109.96 3.65 1381915426 0.00 0.00 slist_iterator_tpl<warenziel_t>::get_current() const
1.44 113.44 3.48 1438259138 0.00 0.00 karte_t::gib_einstellungen() const
1.33 116.67 3.23 18980169 0.00 0.00 convoi_t::calc_acceleration(long)
1.30 119.81 3.15 32281602 0.00 0.00 convoi_t::sync_step(long)
1.27 122.87 3.06 434896895 0.00 0.00 slist_iterator_tpl<hashtable_tpl<sync_steppable*, sync_steppable*, ptrhash_tpl<sync_steppable*> >::node_t>::next()
1.24 125.87 3.00 204733482 0.00 0.00 karte_t::ist_in_kartengrenzen(short, short) const
1.20 128.77 2.90 1435409371 0.00 0.00 einstellungen_t::gib_max_hops() const
1.20 131.66 2.89 1027928457 0.00 0.00 vector_tpl<route_t::ANode*>::operator[](unsigned int)
1.17 134.48 2.82 161567383 0.00 0.00 ding_t::get_flag(ding_t::flag_values) const
1.14 137.24 2.76 197284070 0.00 0.00 grund_t::gib_hoehe() const
1.03 139.74 2.50 287359649 0.00 0.00 koord3d::gib_2d() const
1.01 142.17 2.43 400544479 0.00 0.00 koord::koord(short, short)
1.00 144.60 2.42 145222083 0.00 0.00 vehikel_basis_t::fahre_basis(unsigned int)
Full logfiles are found here: http://www.simutrans-germany.com/files/upload/simutrans.zip
suche_route() is 44s versus 29s/33s which accounts nearly for the difference intotal time. Interestingly vector_tpl<ware_t>::operator[](unsigned int) and vector_tpl<ware_t>::get_count() const (3.12s and 2.59s are in the top routines, while in the old code they are much further down 2.15s and 1.01s). Also memory consumption is of course worse 39,64 MB versus 42,48MB or 42MB for caching only. (The percentage most likely change due to the time for image drawing even though minimized.)
In the moment it seems that your version consumes more memory is slower [and as a feature? has not a max_hop limit (which is essential with multiplayer. Otherwise with a single public interchange all poeple will find a rout over it, even though the exceed the maximum hops clearly.]
If it is of any consolation, also my caching is not very effective apparently and mainly east up memory, as was multithreading and a zillion (ok, less than ten) other attempts I did there. Even more, nothing seems broken (apart from p****engers finding a route that are too long in transit imho), so programmingwise you did a good job.
What I learned from this profiling session is that we need a new grafik driver without an interface to get reliable profiling. Also the impact of different random generator settings is really huge, thus even three mont are too short (but they took about 20min per run on my machine
)