Productivity is not = hours worked.
Productivity is not = hours worked.
How do you measure a programmer's productivity when you can't estimate exactly (and sometimes not even close) how much work something should take?
What I've found useful, and which worked reasonably well for teams which have been working over a period of time together is to collectively estimate complexity of tasks that must be completed.Say on a scale of 1-5. That gives you a reasonably agreeable scale of measurement (not a universal scale, but the one that the team accepts). As time progresses, you see how many such tasks are completed by any person in a given time frame.
Not that this is foolproof, or that it works right from the beginning of a project, but over a period of time, you tend to get a good sense of how productive each member is.
[Edit: Typo fixed]