As already stated, it depends on the car, more so on the engine in the car. A good visual is a chart showing the power and torque curves like
this one . The darker line is the torque curve and the lighter line is the power curve. As you can see, the torque peaks at just over 4000 rpm. With my understanding, the most efficient time is to shift right at the top of the torque curve, however, if you do not need to gain much more speed, shifting at a lower rpm is probably more efficient. Also, the power efficiency is such that shifting at the top of the torque curve should give you the best acceleration, not shifting at redline as greencactus said. Running the engine at lower rpm's is better in the long run. It is more efficeint on gas and causes less wear on the engine. An engine will last the longest if it is running
smoothly at the lowest possible speed without stalling.