Attack speed
See Weapon Speed for tables summarising this information.
When deciding between two different weapons, it can be helpful to understand exactly how attack speed works. Each physical attack in Crawl causes a certain amount of delay, which is the amount of time measured in auts before you can act again. A character with a small attack delay will swing more frequently than a character with a large attack delay. As this greatly multiplies the damage you can inflict in combat, it is strongly recommended to get your attack delay as low as possible.
Base and adjusted attack delay
The base attack delay of a weapon is listed upon examination. For example, examining a hand axe shows that its speed is 130%. To convert this to base delay, simply chop off the last 0. Our handaxe has a base delay of 13, meaning it takes 13 auts to recover from your attack.
Having skill levels in a weapon's associated skill will decrease this delay. Take your weapon skill and divide it by two, rounding down. Subtract the result from the weapon's base delay to determine your adjusted delay. So if you have a skill of 2 in Axes, your hand axe would have an adjusted delay of 12. As soon as you reached a skill of 4 in Axes, the adjusted delay would decrease to 11.
Minimum delay
Now, weapons can't just keep getting faster and faster. All weapons have a minimum delay. Once reached, more weapon skill won't decrease the delay any further (but will still improve your damage and accuracy). To find out the minimum delay for a particular weapon, take the base delay, divide it by two, and drop the remainder. So, our handaxe with a base delay of 13 has a minimum delay of 6. That means that our weapon skill can at most lop seven points off of the hand axe's base delay. Once you hit an Axe skill of 14, that hand axe is going to be swinging as fast as it is going to get.
Exceptions
There are a couple of exceptions to the minimum delay calculation. First, if the weapon in question is a short blade and the calculated minimum delay is larger than five, then the minimum delay is adjusted to five. So that sabre, even though it has a base delay of 12, has a minimum delay of 5 instead of 6.
The second exception is if the calculated minimum delay is larger than seven. In such a case, the minimum delay is set to seven. This mostly happens with big two handed weapons. Because of this exception, that executioner's axe of yours with a base delay of 20 has a minimum delay of 7 instead of 10.
There is also hard-coded minimum player weapon delay of 3. If the calculated minimum delay is less than three it set to three.
The speed brand comes into effect after the check against the minimum attack delay is done. A weapon with the speed brand can actually attack faster than the calculated minimum delay. The speed brand halves delay, rounding up. So a hand axe of speed, at an Axe skill of 14, would have a delay of 3 instead of 6. An executioner's axe of speed would have a delay of 4 instead of 7 at an Axe skill of 26.
Shields can potentially add extra delay to your attacks. To calculate the delay added, you first need to know your adjusted shield penalty:
(adjusted shield penalty) = (base shield penalty) - (shield skill)/(racial divider)
The base shield penalty is 1/3/5 for bucklers/shields/large shields, and the racial divider is 3/5/7/9 for large/medium/small/little characters. Throw away any remainder on the division. So a medium size character would have an adjusted shield penalty of 0 when wielding a buckler at shield skill 5, a shield at shield skill 15, and a large shield at shield skill 25.
Two random integers are chosen between 1 and your adjusted shield penalty. The smaller one is used as the delay added by the shield. Once your adjusted shield penalty reaches zero there is no added delay.
At this point, if the weapon delay plus the shield delay is less than three, it is set to three. This is only an issue when wielding a quickblade of speed.
Final modifiers
So, now we have an adjusted weapon delay after taking our weapon and shield into consideration. We aren't done yet. If slowed or in Statue Form, this value is multiplied by 1.5. If we are hasted or berserk, it is divided by 1.5. Under Finesse, it is divided by 2. The result of this calculation is an integer, but whether it is rounded up or down is randomized, weighted by the reminder.
What does that mean, you ask? Say you are wielding a demon whip, and have enough mace skill to reach the minimum delay of 5. You berserk. The berserk divider is 1.5, so your delay value is 3.333. Delays must be integer values though, so 2/3 of the time your delay will be rounded to 3, and 1/3 of the time your delay will be rounded to 4. In effect, you get your delay of 3.333.
The smallest delay you are allowed to swing with is 2. If the final calculation spits out a value less than 2, it is set to 2. That means that the speed bonus of Finesse only works at partial effectiveness for attacks with these weapons. Finesse will reduce the delay from 3 to 2, and not to an average of 1.5 (Bear in mind that this still results in a massive boost to damage output).
The functions which calculate the delay can be found in melee_attack.cc. See melee_attack::calc_attack_delay and its sub-functions.
http://git.develz.org/?p=crawl.git;a=blob;f=crawl-ref/source/melee_attack.cc