There is your question, and there is a question under that which deserves to be addressed. First, your question:
Productivity is actually easy to measure. How many useful discrete units are produced. If you're measuring lines of code, then how many lines of code have a bug in it? The person with the higher number of bug-free lines is more productive.
This article from Harvard Business Review all the way back in 1983 addresses some statistical ways to look at defects and productivity. Nothing has really changed since then.
Now the question under the question: does it matter? It is likely that it doesn't.
If I gave you a file with 10000 lines of code, would it help you? Probably not. It has to be the right code that does the right things. Even to the point of quality, does a bug exist in a single line of code? Sometimes, but often it stems from how multiple lines of code interact. Or, to be almost silly about it, would you rather have this code:
if (a > b)
{
return a;
}
else
{
return b;
}
than this code:
return (a > b) ? a : b;
If you don't happen to code, those two snippets do exactly the same thing.
Therefore, it can help us to think less in terms of productivity and more in terms of effectiveness. When a business problem arises, how long does it take for us to solve that problem? How effective are we at prioritizing the most important work?
What I encourage teams to do is to look at how their users measure the value of the development team. One team I worked with automated process, so the primary value driver was the amount of time their users took to successfully complete a particular transaction. This could be achieved through fewer steps in the automated process, reduced user error, and many other things. Measuring how effective the team is at serving their users is almost always more useful than measuring how many artifacts they produce.
Of course, it's almost impossible to separate who did what at an individual level, but that's probably fine. As Yves Morieux elegantly shares in his TED talk, when we demand individual accountability, what we often get is a situation where we may never succeed, but we'll always know who to blame when we fail.