The most reliable test I found, and by accident, was fighting bots on a certain Quake 3 map
For me, it's playing a TF2 Scout on a well-populated server running a Scout-friendly map. A kill/death ratio of 3:1 or greater means that I'm sharp, 2:1 is okay, and 1:1 or lower means that I'm sluggish.
However, in my case, using a game (especially a twitch-aim FPS) as a performance test defeats the purpose of testing because it primes me away from the task I've planned for the day and considerably shortens my attention span, so I never play anything before work.
How do you test yourself?
I think the best test is the task itself. Instead of testing, I just take a stab at the planned task. When I feel that I'm not performing well (I usually can tell that fairly quickly), I try to downshift to a less demanding subtask within the same task (to keep the priming advantage) and see how well I perform there. Quite a few times I manage to get into "the zone" and upshift back to the original task.
In general, my approach to bad days is not "how do I test if I have a bad day?" but "how do I squeeze the maximum progress out of a bad day?" The approach boils down to a series of downshifts to less demanding but still useful tasks. My typical bad day looks like this: thinking about the #1 item on my todo list, feeling dumb, discussing small problems (e.g. minor GUI tweaks) with the programmers, feeling dumb again, and ending up with declaring an Errand Day (mostly reacting to email).
(What I described above is a "good bad day". A "bad bad day" is when I slide into procrastination at the start of a day and remain useless for the rest of it -- which, thankfully, doesn't happen that often.)
We all have our good days and our bad days. Due to insufficient sleep, illness, stress, distractions, and many other causes we often find ourselves far below our usual levels of mental performance. When we find ourselves in such a state, it's not really worth putting effort in doing many tasks, like programming or long term planning - as quality will suffer a lot.
The problem is - other than observing deterioration of results, I have no idea if I'm in such a state or not. I cannot be sure if it's also true for others, but I had to find out a few tests of what's my mental performance at the moment. Tests that are deeply flawed, so I'd request better if there are any. I also cannot predict my mental state in advance, as my life isn't terribly regular.
The most reliable test I found, and by accident, was fighting bots on a certain Quake 3 map - me vs 10 or so highest difficulty bots. The challenge was to get 50 frags without dying. As the map was huge and full of power ups, it wasn't really that difficult as long as I could maintain full alertness for 10-15 minutes - but if I was tired or distracted, I would invariably fail. This test was unfortunately extremely slow.
Another test would be to go to goproblems, and do a few random problems at proper difficulty level. If I could think right, I would do most of them, if I was tired, I would fail almost 100%. This didn't test alertness, I guess it would be best described as short term memory test, as that's what used for game tree exploration. Unfortunately what's the proper difficulty varies a lot with how much go I played recently, so it needs to be recalibrated.
One more test would be to go to some decent online IQ test like this one. My results on such test would suffer a lot if I was sleepy or tired. The main problem is that such tests cannot repeated too often, or I'd just remember the answers.
So these are three ways to test how well my mind functions at the moment, all testing something different, and all flawed in one way or another.
How do you test yourself?