|
Complete.Org:
Mailing Lists:
Archives:
freeciv-dev:
February 2002: [Freeciv-Dev] [Patch] Micro optimization of food_weighting |
|
[Freeciv-Dev] [Patch] Micro optimization of food_weighting[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
[ I shouldn't do such micro optimization, but it was tempting ]
server/citytools.c's food_weighting takes an int and returns an
int. It doesn't reference any global data but contains an expensive
div.
Running the attached test.c:
gcc -O2 test.c
- old version
user 0m12.430s
user 0m12.300s
- new version
user 0m6.160s
user 0m6.150s
- empty function
user 0m3.000s
user 0m2.990s
gcc -O3 test.c (this enables inlining)
- old version
user 0m9.830s
user 0m9.850s
- new version
user 0m2.380s
user 0m2.390s
- empty function
user 0m0.780s
user 0m0.790s
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Many of my assistants were fans of Tolkien, who wrote 'Lord of the Rings'
and a number of other children's stories for adults. The first character
alphabet that was programmed for my plotter was Elvish rather than Latin."
-- from SAIs "life as a computer for a quarter of a century"
|