The answer is "until it's good!"
That may seem a bit facile, but it's substantially the truth. And it largely depends on the effect, your skills, your standards and methods of rehearsing, and so forth. It helps to practice the bits and pieces separately sometimes, going over a sleight repeatedly, for example, until it feels natural. Then incorporate the steps and link them together. Then go over the whole routine from start to finish without stopping even if you make a mistake (because you'll have to keep going no matter what happens when you have an audience watching.) This is the real rehearsal
part. Eventually, you'll achieve a level of comfort with the effect that suits you and the only thing left to do is to do it. Your audience will let you know if the rehearsal was enough! By going through this process a few times with different effects, you'll find a process that works predictably well in most cases.
Best of luck!