http://www.webmd.com/balance/caffeine-myths-and-facts And (Deadtree): Barone, J.J. and Roberts, H.R. Food and Chemical Toxicology, 34, 119-129, 1996.
It is commonly suggested to avoid caffeine 8 hours before bed to be able to sleep well.
--
If it lasts that long for you (and you're not on birth control or pregnant), you may wish to get liver function tests done with your doctor to make sure you're okay in that department.
Or you may just need to do other steps to put you into deeper sleep. Cold rooms with warm blankets, nothing but sex and sleep in bed (no reading, no talking, no snoozing), no spicy or sweet foods within a few hours before bed and block out all/most light to help.
You either A> are being inconsistent, B> Don't understand half-life or C> are overstating your case. Look, you said before you think it's only useful in the morning, then you say:
>If I don't stop 6 hours before bed it affects my performance the next day.
So either you go to bed at 6pm, or you aren't saying the same thing about when you find caffeine useful vs when it effects your sleep as you originally claimed it was only useful in morning.
Additionally, the crash from stimulants is from adrenaline rush and a dip in serotonin.
If you're taking a modest amount of caffeine, you shouldn't be suffering a downswing. Only heavy users (400+ mg a day, usually addicts) are likely to actually have a serotonin dip, and only large doses cause a large enough adrenaline surge for you to feel a crash similar to what you'd feel on a stronger stimulant like amphetamines.
The best use case for caffeine is: No daily usage, less than 400mg per day when used, used as late in the day as required to stay awake (and remember it lasts for about 4-8 hours longer than you are drinking it), but not in the morning. Get your heart racing in the morning by a set of jumping jacks or something else, and watch for signs of addiction and tolerance.
And now, I'm invoking XKCD and ignoring the rest of this thread so I can get some code released: http://xkcd.com/386/
There's two issues with caffeine for me : performance dip and sleep interference. If I drink a cup of coffee, I feel the boost but when it wears off, I feel a performance dip. Perhaps I am more sensitive to this than average, I don't care what the exact reason is. I can't comment on how this compares to speed or other drugs, I'm relatively straight edge. It's a relatively mild down, but enough to impact my performance. So, my inclination is to re-up caffeine to stave off the downswing, which cannot continue past lunch due to the impact on my sleep. So, that is why I comment on how it's only useful in the "morning". Different people have wildly different metabolisms, body compositions and reactions to drugs - I tend to be very sensitive to drugs... I got pulled over for suspected DUI once and blew a 0.03 :]