Comprehensive tests on the density-modification methods charge flipping [Oszlanyi & Suto (2004). Acta Cryst. A60, 134-141] and low-density elimination [Shiono & Woolfson (1992). Acta Cryst. A48, 451-456] for solving crystal structures are performed on simulated diffraction data of periodic structures and quasicrystals. A novel model-independent figure of merit, which characterizes the reliability of the retrieved phase of each reflection, is introduced and tested. The results of the performance tests show that the quality of the phase retrieval highly depends on the presence or absence of an inversion center and on the algorithm used for solving the structure. Charge flipping has a higher success rate for solving structures, while low-density elimination leads to a higher accuracy in phase retrieval. The best results can be obtained by combining the two methods, i.e. by solving a structure with charge flipping followed by a few cycles of low-density elimination. It is shown that these additional cycles dramatically improve the phases not only of the weak reflections but also of the strong ones. The results can be improved further by averaging the results of several runs and by applying a correction term that compensates for a reduction of the structure-factor amplitudes by averaging of inconsistently observed reflections. It is further shown that in most cases the retrieved phases converge to the best solution obtainable with a given method.