How much sleep is needed for peak cognitive performance? If some were to, for example, wake up one morning at 12:30PM, would a sleeping pill help obtain better sleep required for that performance the next morning at 08:00AM? And when would the optimal time be for the consumption of that sleeping pill? Is the amount of drawbacks in cognitive performance perceptible for 4.5 hours of sleep vs. 7 hours of sleep?
How much sleep is needed for peak cognitive performance. If some were for >example wake up one morning at 12:30 pm would a sleeping pill help obtain >better sleep required for that performance the next morning at 08:00 am ?
It depends on what pharmacotherapies - per the clinical judgement of their treating physician - one may have consumed. Conceptually, we might consider the two most psychopharmacologically relevant agents to be psychostimulants (coll. "uppers") and sedatives (coll. "downers" aka "goofballs").
Regarding sedatives, one's biggest concern would be a residual hangover effect. This is influenced by the agent's half-life (t½). For future reference, some 8 drug half-lives are needed for complete elimination. A short-acting benzodiazepine such as midazolam (t½ = several hours) is less likely to have residual effects than a long-acting barbiturate such as phenobarbital (t½ = 100+ hours). Non-benzodiazepine sedatives such as zolpidem appear so-so with regards to hangover, zaleplon seems to fair considerably better . sedating antihistamines are horrendous . If one had an enterically-coated "XR" tablet, one might do well to crush it up before swallowing, to ensure a more amenable pharmacokinetic profile.
Is it perceptable the amount of drawbacks in cognitive performance in a situation of 4.5 hrs of sleep vs 7 hrs of sleep?
First, a caveat: individual differences apply here . You know the answer for your own cognitive faculties better than anyone else. Interestingly, here is one paper that shows relatively modest drops in performance after acute sleep deprivation; chronic sleep deprivation, however, appears to have a deleterious dose-dependent effect .
Of direct relevance to your actual question, the above study notes:
Based on these findings, it appears that the inflection point (i.e. the minimum amount of nightly sleep required to achieve a state of equilibrium in which daytime alertness and performance can be maintained at a stable, albeit reduced, level) is approximately 4 h per night. 
Who'd've thunk, right?
The issue boils down to this:
Will the time you spend attempting to encode new memories into your LTM be more beneficial than the loss in attentional and executive function, as well as loss of potential REM-related memory consolidation and subsequent recall at the time of your examination?
When it comes to one's own therapeutic needs, it is always prudent that one consult with their treating physician. Here are my own reckless thoughts on the matter:
Ideal situation: if one's healthcare practitioner has prescribed them the sedative sodium oxybate (better known as GHB), then per oral administration of 4-5 grams GHB, followed by rapid onset of 4 hours of deep, refreshing sleep, might be indicated . It would appear very unfortunate that GHB developed a reputation as a date rape drug, as anecdotally, some individuals consider it the "perfect sleep aid", particularly during exam periods.
If one's healthcare practitioner has prescribed them any of the following psychostimulants: d-amphetamine , modafinil  or perhaps methylphenidate they may wish to consider - per the recommendation of their physician, of course - skipping sleep entirely. Obviously, this is contingent upon their ability to recover following completion of their work, study or family-related responsibilities, but may result in greater performance relative to brief, fragmented sleep.
If one's healthcare practitioner has prescribed them a short-acting benzodiazepine, one may still find that their sleep disorder is refractory and follows this particular clinical course: sleep from 10 pm to 2-4 am, awakening, titration of caffeine as indicated. They may find that 4-6 hours post-awakening, their cognitive abilities are better than had they slept the same amount of time and awoken closer to 8 am.
Remain valiant, soldier. Some people's best exam performances have come from around 3-4 hours of broken sleep care of a third of a bottle of Jack Daniels.
 A comparison of the residual effects of zaleplon and zolpidem following administration 5 to 2 h before awakening http://onlinelibrary.wiley.com/doi/10.1046/j.1365-2125.1999.00024.x/epdf
 Next-Day Residual Sedative Effect After Nighttime Administration of an Over-the-Counter Antihistamine Sleep Aid, Diphenhydramine, Measured by Positron Emission Tomography http://journals.lww.com/psychopharmacology/Abstract/2010/12000/Next_Day_Residual_Sedative_Effect_After_Nighttime.9.aspx
 Inter- and intra-individual variability in performance near the circadian nadir during sleep deprivation. http://onlinelibrary.wiley.com/doi/10.1111/j.1365-2869.2004.00429.x/full
 Patterns of performance degradation and restoration during sleep restriction and subsequent recovery: a sleep dose-response study. http://onlinelibrary.wiley.com/doi/10.1046/j.1365-2869.2003.00337.x/epdf
 Enhancing Slow Wave Sleep with Sodium Oxybate Reduces the Behavioral and Physiological Impact of Sleep Loss. http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2938863/pdf/aasm.33.9.1217.pdf
 Modafinil, d-amphetamine and placebo during 64 hours of sustained mental work. I. Effects on mood, fatigue, cognitive performance and body temperature. http://onlinelibrary.wiley.com/doi/10.1111/j.1365-2869.1995.tb00172.x/abstract
 Personal communications with myself.