Quantifying algebraic properties of surface groups and 3-manifold groups