The purpose of this paper is to set up a formalism inspired by non-Archimedean geometry to study K-stability. We first provide a detailed analysis of Duistermaat-Heckman measures in the context of test configurations for arbitrary polarized schemes, characterizing in particular almost trivial test configurations. Second, for any normal polarized variety (or, more generally, polarized pair in the sense of the Minimal Model Program), we introduce and study non-Archimedean analogues of certain classical functionals in Kähler geometry. These functionals are defined on the space of test configurations, and the Donaldson-Futaki invariant is in particular interpreted as the non-Archimedean version of the Mabuchi functional, up to an explicit error term. Finally, we study in detail the relation between uniform K-stability and singularities of pairs, reproving and strengthening Y. Odaka's results in our formalism. This provides various examples of uniformly K-stable varieties. Contents 56 9. Uniform K-stability and singularities of pairs 58 Appendix A. Asymptotic Riemann-Roch on a normal variety 66 Appendix B. The equivariant Riemann-Roch theorem for schemes 67 References 69