Its worth noting that the mass spectrometer actually measures the mass to charge ratio, not just the mass, however if you are dealing with atoms of the same element they will all have the same charge when ionized and thus you are effectively measuring the mass.