I agree that comparing to others is mentally unhealthy. This applies not only to the gym/fitness but all areas of life. On the other hand, measuring progress is a good motivator, and I feel a proper way to do that is to challenge yourself. If you were able to shave X seconds off your mile time, or improve your squat weight by Y pounds, then I feel it is a proper motivating factor as well as one that could assist in keeping your mental attitude in the right place when other facets of your life are troubling.