TL;DR
DO perform CPR as soon as one stops breathing normally and is irresponsive, and don't stop. PERIOD. To be on the safe side, even perform CPR on people you presume to be dead for a longer period of time. There are certain definitive signs of death that doctors will use to pronounce a patient dead.
There is a difference between dead and dead
As a rule of thumb, for every minute without oxygen, the chances of survival decrease by roughly 10% because of irreversible brain damage.
Holmberg M. et al, (2000), "Effect of bystander cardiopulmonary resuscitation in out-of-hospital cardiac arrest patients in Sweden", Resuscitation, 47:59-70
The picture below is completely unscientific and has been drawn by me, with no data whatsoever, because I couldn't find any free-to-access statistics to prove my point. (The full version of the linked article. and quite a few other studies performed on this issue have data supporting this general trend).

Source: completely unscientific trend lines mingled together by me.
At some point, time has advanced so far that the patient has zero chances of survival left because the brain damage was too severe.
A patient is clinically dead as soon as they enter cardiac arrest (i.e. no oxygen circulation), but this status is reversible. However, due to ongoing brain damage due to lack of oxygen, the patients chances of survival decrease until they reach 0%, at which point a doctor will pronounce them (actually) dead.
So when do I perform CPR?
Simple, the European Resuscitation Council has published guidelines, the latest version (2015, as of now) says the following:

Source: Perkins, Gavin D. et al. Official Guidelines of the European Resuscitation Council, latest edition: 2015. Section 2, p.85
By the way, the guidelines are free to access, and definitely worth a read!
So as soon as the patient is unresponsive and not breathing normally, you should call the emergency services and start CPR. Even if you don't know how long they have been in this state of cardiac arrest, there are chances of survival. Once a doctor arrives, they will continue with CPR and/or pronounce the patient dead.
What about really dead people?
Of course, there is no gain in trying to reanimate a corpse that has been dead for a few days, and in this case it comes in handy to know if the patient was actually dead for a longer period of time.
You will know. Don't judge by the coldness (cold actually improves the chances of survival), but there are so-called certain signs of death.
- Lethal injuries:
This is actually quite obvious: If the patient is decapitated or otherwise so severely injured that it is simply impossible to survive, they are dead with a very high certainty. CAVE: Be careful about your own safety!
- Pallor mortis:
This is a paleness due to no circulation in the capillaries of the body. Gravity pulls the blood lower.
- Algor mortis:
The reduction in body temperature. CAVE: Depend highly on environmental factors, drowning patients will be quite cold and still have chances of survival
- Rigor mortis:
A stiffness in the body. For muscles to relax, ATP needs to be present, and because in a corpse, no ATP is produced/circulated, the muscles become stiff.
- Livor mortis:
The blood has been pulled down by gravity so that it forms a red decolorisation of the skin.
- Decomposition:
The proteins get broken down, the muscles relax because the binding proteins also get degenerated. This is accompanied with a strong odor.