The most straightforward options is the built-in benchmark package.
Its usage is remarkably simple:
(benchmark 100 (form (to be evaluated)))
It’s autoloaded, so you don’t even need to require it.
Benchmark is good at overall tests, but if you’re having performance
problems it doesn’t tell you which functions are causing the problem.
In addition to @Malabara's answer, I tend to use a custom-made with-timer macro to permanently instrument various parts of my code (e.g my init.el file).
The difference is that while benchmark allows to study the performance of a specific bit of code that you instrument, with-timer always gives you the time spent in each instrumented part of the code (...
In addition to @Malabarba's answer, note that you can measure the compiled execution time of your code with benchmark-run-compiled. That metric is often much more relevant than the interpreted execution time that M-x benchmark gives you:
ELISP> (benchmark-run (cl-loop for i below (* 1000 1000) sum i))
(0.79330082 6 0.2081620540000002)
I don't know of any good performance benchmark for Emacs, sadly.
Part of the reason is that it depends on what you want to measure (redisplay performance? I/O performance? ...).
Regarding Elisp performance in particular, the lack of benchmark is a symptom of the relative lack of work on improving its performance. FWIW, when working on the implementation ...
Benchmarking is not only about getting the numbers, it is also about making decisions based on result analysis.
There is benchstat.el package on MELPA which you can use to get features that benchstat program provides.
It implements comparison-based benchmarking where you examine X performance properties against Y.
Benchstat functions can be viewed as a ...