I feel a little compelled to post, but the Motors collective have gone over this topic a number of times before. We definitely need a Motors subject matter FAQ for things like this!
For maximum performance, the appropriate time to shift up is where the torque produced at the wheels minus drag in the next gear, is greater than the torque produced at the wheels minus drag in the current gear.
In effect, this means it is very much dependant on your gear ratios and torque curve, with a small dependence on drivetrain efficiency (measured from flywheel to the road, as the amount of drive being applied to the road is the most important thing).
If you are struggling with the concept, remember a few key things:
1) The engine produces torque at the flywheel at a certain RPM
2) The transmission and final drive gears this torque by reducing the RPM in order to increase the torque
3) One revolution of the engine transmits directly in to 1/X revolutions of your drive wheels, where X is the transmission and final drive torque multiplication of a specific gear - therefore more torque multiplication equals lower road wheel RPM and thus lower road speed
As an example, imagine you are travelling at 30 MPH in 1st gear. Your engine is producing 200 Nm of torque and it is spinning at 6000 RPM. Let's say the transmission and final drive ratio at this point is 1:1, therefore the torque at the wheels is 200 Nm. If you were to change up in to 2nd gear, the engine revs may drop to 4000 RPM. At this point the engine itself may produce 250 Nm, but to drop the RPM to 4000 RPM and retain a road speed of 30 MPH a ratio of 0.666:1 must be applied. This ratio has the effect of reducing the torque output to 0.666 * 250 Nm, or 167 Nm - less than the 200 Nm it was putting to the wheels in 1st. Therefore, the car accelerates slower. It would probably be practical in this example to continue accelerating in 1st gear until the engine is producing so little torque than the 0.666:1 gearing ratio in 2nd is overcome. I have ignored it for this example, but the drag/drivetrain loss is proportionally higher at higher RPM, so this is a (small) benefit of accelerating in lower gears.
If you have a good dyno printout and your gear ratios it can be calculated relatively accurately. Even better if you have a dyno printout with drivetrain loss.