We compare the performance of quantum annealing (QA, through Schrödinger dynamics) and simulated annealing (SA, through a classical master equation) on the p-spin infinite range ferromagnetic Ising model, by slowly driving the system across its equilibrium, quantum or classical, phase transition. When the phase transition is second-order (p = 2, the familiar two-spin Ising interaction) SA shows a remarkable exponential speed-up over QA. For a first-order phase transition (p ≥ 3, i.e., with multi-spin Ising interactions) , in contrast, the classical annealing dynamics appears to remain stuck in the disordered phase, while we have clear evidence that QA shows a residual energy which decreases towards 0 when the total annealing time τ increases, albeit in a rather slow (logarithmic) fashion. This is one of the rare examples where a limited quantum speedup, a speedup by QA over SA, has been shown to exist by direct solutions of the Schrödinger and master equations in combination with a non-equilibrium Landau-Zener analysis. We also analyse the imaginary-time QA dynamics of the model, finding a 1/τ 2 behaviour for all finite values of p, as predicted by the adiabatic theorem of quantum mechanics. The Grover-search limit p(odd) = ∞ is also discussed.