Rather than the vague and rude how longs a piece of string?
the DSA recommends around 45 hours of professional training plus additional private practice to give you the best chance of passing. However, everyone learns at a different pace and lives in a different place (next to the test centre/area is clearly better than 20-30 minutes away) and there is no magic ‘modus operandi’ to answer that question. Your instructor will tailor all lessons to suit you and will recommend the best time to take your test. If you’re not getting it consistently right with your instructor, then you’re not ready to take the test.