[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[glob2-devel] Optimisation of the gradients. Pointer vs integers.
From: |
Nuage |
Subject: |
[glob2-devel] Optimisation of the gradients. Pointer vs integers. |
Date: |
Fri, 25 Nov 2005 20:30:46 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20051102 |
> * 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.
- Re: [glob2-devel] my experiments on pathfinding and gradients (huge), (continued)
- Re: [glob2-devel] my experiments on pathfinding and gradients (huge), Andrew Sayers, 2005/11/25
- [glob2-devel] half solved bug when using random maps, Nuage, 2005/11/25
- Re: [glob2-devel] half solved bug when using random maps, Andrew Sayers, 2005/11/25
- Re: [glob2-devel] half solved bug when using random maps, Nuage, 2005/11/25
- Re: [glob2-devel] half solved bug when using random maps, Andrew Sayers, 2005/11/25
- Re: [glob2-devel] half solved bug when using random maps, Stéphane Magnenat, 2005/11/25
- Re: [glob2-devel] half solved bug when using random maps, Andrew Sayers, 2005/11/25
- [glob2-devel] the random map generator (big), Nuage, 2005/11/25
- Re: [glob2-devel] the random map generator (big), Andrew Sayers, 2005/11/25
- Re: [glob2-devel] the random map generator (big), Matthew Marshall, 2005/11/26
- [glob2-devel] Optimisation of the gradients. Pointer vs integers.,
Nuage <=
- Re: [glob2-devel] Optimisation of the gradients. Pointer vs integers., Andrew Sayers, 2005/11/25
- [glob2-devel] smart time-dividing computation of resource gradients idea (new), Nuage, 2005/11/25
- Re: [glob2-devel] smart time-dividing computation of resource gradients idea (new), Andrew Sayers, 2005/11/25
- [glob2-devel] speedup possible on resource gradients, Nuage, 2005/11/25
- Re: [glob2-devel] speedup possible on resource gradients, Andrew Sayers, 2005/11/26
- Re: [glob2-devel] speedup possible on resource gradients, Nuage, 2005/11/27
- Re: [glob2-devel] speedup possible on resource gradients, Andrew Sayers, 2005/11/27
- [glob2-devel] resource gradients, Nuage, 2005/11/25