I've looked at a similar comparison (9mm vs. 357mag) out of short barrels and what I've found is that the .357mag doesn't show much of an advantage until you get to the 3-4" barrel range.
A friend of mine bought a Ruger SP101 with a 2.25" barrel and I ran some numbers, and my 3" Kahr CM9 actually has about the same or slightly better ballistics than his .357.
If you really want to get the advantages of a .357 I'd go with a barrel of at minimum 3", but more likely 4".
Check out the website ballisticsbytheinch.com for some comparisons of different calibers out of different length barrels. It's pretty easy to compare performance there if you pay attention to bullets with similar weights.
Long story short, if I was deciding between the two, I'd probably go with the Glock or Ruger in .40 because simply put, the .40 is a little bit larger (diameter) so all things being equal (speed, bullet weight), the .40 should do more damage.