Undulator rms phase error is expressed as function of the magnet peak field distribution. It can be used as the objective function for practical undulator performance optimization. An simple analytical computation formula is given for field signature of the shims to predict the field and phase perturbation according the shim position, size, thickness and magnet gap.