4754: Move perf/prof deps to :test/:performance groups.
Move "do not reset unless Rails.env==test" logic into one place.
Merge branch '4754-performance-TC' closes #4754