  We compare the performance of quantum annealing (QA, through Schr\"odinger
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 \ge 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
$\tau$ 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\"odinger 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/\tau^2$
behaviour for all finite values of $p$, as predicted by the adiabatic theorem
of quantum mechanics. The Grover-search limit $p({\rm odd})=\infty$ is also
discussed.
