Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] [Patch] Micro optimization of food_weighting
Home

[Freeciv-Dev] [Patch] Micro optimization of food_weighting

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] [Patch] Micro optimization of food_weighting
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 23 Feb 2002 10:06:10 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

[ 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"

Attachment: test.c
Description: Text document

Attachment: food_weighting1.diff
Description: Text document


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] [Patch] Micro optimization of food_weighting, Raimar Falke <=