How do you know the difference between fruitful perseverance, and banging your head against the wall to your own detriment?

How do you know the difference between fruitful perseverance, and banging your head against the wall to your own detriment?
What’s it like to do something hard for a long time and to succeed?