So, in short, it depends on the piece. If you have all the techniques necessary down and can "walk" through it slowly without being uncomfortable, then I say it takes however long it takes. It doesn't matter.
Two nuggets of extreme wisdom here. "It takes however long it takes" and "It doesn't matter"
We're all guilty of rushing to "perfect" a piece, any piece, every piece, whatever "perfect" may mean, and in so doing we forget the biggest and most important single thing - it needs to have some enjoyment for us.
I played Carulli's Overture Op 6 Nr 1 at my Grade 8 exam, and had it reasonably under my fingers (I got a distinction). But I didn't like the piece, so I've never played it since; not at solo concerts, not in practise sessions, not once. Never. And I'll probably never look at it again.
In the same exam, I played Capricho Arabe. I still play it a lot and I'm still looking for ways to make my enjoyment of that piece, and that audience's, even better. I've also played it at 17 solo concerts this year and at audition to become a peripatetic guitar teacher in the UK, a role I start next week.
So, IMO there are several levels of mastery. First there is the level where you're happy playing it to yourself. Second there is the level where you're happy playing it to others. Third is the level where David Russell/ John Williams/ Ana Vidovic etc play that same piece because that's where you want to get to. And fourth, finally, is the level at which you would personally trust that piece to project you as a competent guitarist to a paying audience. I reckon, if you put number four between numbers two and three, you'd see a lot more classical guitar concerts being given.