What determines which powder gives you the fastest bullet speed (FPS) for a given cartridge and how does barrel length effect this?
Zak covered this pretty bloody thoroughly, but I'd like to add a few ancillary thots. There are many factors other than barrel length and powder speed (oxidation rate) that can affect the pressure curve.
For example, heavy neck tension or a crimp can dramatically increase PEAK pressures (and velocity). This effect can, if applied intelligently and judiciously, allow the use of 'slower' powders than might otherwise be the norm - effectively 'lengthening the barrel' by artifically constraining the gases to a smaller volume for a longer period of time. Put a light crimp a caseful of 2400 in your 357Mag and then try the same load with a heavy crimp, and you'll both see and be able to measure on a chrono the difference in velocity. (Try that same experiement with a max load of a faster powder, and you may get to wear parts of the receiver in your forehead as you create a pressure spike that's too much for the action to handle..)
Along the same line of thought, the shape of the case can impact flame front propagation and therefore cause slower-than-expected or faster-than-expected pressure rises. In straightwall pistol cases, this isn't really an issue but it is certainly a factor in bottleneck rifle chamberings.
Another factor is the primers used. Some primers create a larger flame nucleus than others, causing a delta in the pressure curve based upon the amount of powder that is initially ignited. This effect is usually pretty subtle, but I've seen instances (mostly with ball powders, mostly in rifles) where changing the primers created a +-10% delta in velocity with no change in accuracy.
None of this is meant to imply that some basic common sense (as Zak detailed) with regard to burn rates and barrel lengths doesn't apply. I'm simply trying to point out that there are additional variables that let you wiggle around a bit within the basic parameters.