Improve timeout calculation.
Improve timeout calculation.

Remove string processing in favour of maths.
Move sec/usec calculation inside condition so they're not calculated when not needed.

amphp/amp,staabm/amp,staabm/amp,kangkot/amp,DaveRandom/amp