> * Optimisation > > You're right that STL-style iterators don't magically speed the code up, > but they do enforce better programming practice, and make the code > easier to manage. > > For example, the gradient update algorithm was using index-based > iterators rather than pointer-based ones. Changing that over lead to a > significant speed increase. With an iterator class, a pointer would > have been used automatically. By requiring the whole program to use > an iterator class, we can ensure that the right type of iterator is used > for every iteration in the program.
How did you measured this ? I ran into both codes. And AFAIK, pointer are integers in the computation point of view. Then I see no way how one to be faster than the other one. I would really be surprised if anything would change. As I really want to understand what's happening, I decided to test it. I ran, both algorithms with the exact same game events. I ran a saved game or mine for 45s. It's a 128x128 map. I have no optimisation activated. No other significant process are running on my CPU. Into Engine.log I found this: With your new algorithm: cpu usage graph: 100.0 % | * 98.5 % | 95.0 % | 93.5 % | 90.0 % | 88.5 % | 85.0 % | 83.5 % | 80.0 % | 78.5 % | 75.0 % | 73.5 % | 70.0 % | 68.5 % | 65.0 % | 63.5 % | 60.0 % | 58.5 % | 55.0 % | 53.5 % | 50.0 % | * 48.5 % | * 45.0 % | 43.5 % | ** 40.0 % | ***** 38.5 % | ************ 35.0 % | ************** 33.5 % | ************************** 30.0 % | ********************** 28.5 % | ********** 25.0 % | *** 23.5 % | 20.0 % | 18.5 % | 15.0 % | 13.5 % | 10.0 % | 8.5 % | 5.0 % | 3.5 % | 0.0 % | With my old algorithm: cpu usage graph: 100.0 % | * 98.5 % | 95.0 % | 93.5 % | 90.0 % | 88.5 % | 85.0 % | 83.5 % | 80.0 % | 78.5 % | 75.0 % | 73.5 % | 70.0 % | 68.5 % | 65.0 % | 63.5 % | 60.0 % | 58.5 % | 55.0 % | * 53.5 % | 50.0 % | 48.5 % | * 45.0 % | 43.5 % | ** 40.0 % | *** 38.5 % | ****** 35.0 % | *********** 33.5 % | ********************** 30.0 % | ************************* 28.5 % | ********************* 25.0 % | ******* 23.5 % | 20.0 % | 18.5 % | 15.0 % | 13.5 % | 10.0 % | 8.5 % | 5.0 % | 3.5 % | 0.0 % | I can't see any real differences. This is confirmed by my in-game feeling. Worse, if you take a closer look, you can see that yours is about 2% slower. Now another try. I try a 256x256 game, with "O3 -march=athlon-xp" optimisations. This is more important, because most people can play 128x128 games with no problem, but it would be nice if more people could play 256x256 maps. I run this one for 60s. With your new algorithm: cpu usage graph: 100.0 % | * 98.5 % | 95.0 % | 93.5 % | 90.0 % | 88.5 % | 85.0 % | 83.5 % | 80.0 % | 78.5 % | 75.0 % | 73.5 % | 70.0 % | 68.5 % | 65.0 % | 63.5 % | 60.0 % | 58.5 % | 55.0 % | 53.5 % | * 50.0 % | * 48.5 % | * 45.0 % | * 43.5 % | ** 40.0 % | *** 38.5 % | *********** 35.0 % | ************** 33.5 % | ********************* 30.0 % | ******************************** 28.5 % | ******** 25.0 % | * 23.5 % | 20.0 % | 18.5 % | 15.0 % | 13.5 % | 10.0 % | 8.5 % | 5.0 % | 3.5 % | 0.0 % | With my old algorithm: cpu usage graph: 100.0 % | * 98.5 % | 95.0 % | 93.5 % | 90.0 % | 88.5 % | 85.0 % | 83.5 % | 80.0 % | 78.5 % | 75.0 % | 73.5 % | 70.0 % | 68.5 % | 65.0 % | 63.5 % | 60.0 % | 58.5 % | 55.0 % | 53.5 % | * 50.0 % | * 48.5 % | * 45.0 % | ** 43.5 % | **** 40.0 % | ***** 38.5 % | **************** 35.0 % | ********* 33.5 % | ***************** 30.0 % | ******************************* 28.5 % | ********* 25.0 % | * 23.5 % | 20.0 % | 18.5 % | 15.0 % | 13.5 % | 10.0 % | 8.5 % | 5.0 % | 3.5 % | 0.0 % | Here there is like no differences at all. _______________________________________________ glob2-devel mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/glob2-devel
