Benchmarks
These benchmarks were designed to measure Javascript running time for Mithril in comparison with other popular Javascript MVC frameworks. Javascript running time is significant because the gzipped size of a framework can be misleading in terms of how much code actually runs on page loads. In my experience, page loads happen far more commonly than one would expect in single page applications: power users open multiple tabs, and mobile users open and close the browser very frequently. And as far as templating engines go, the initial page load represents the worst case for the rendering algorithm since there is very little room for performance optimization tricks. It’s arguably also one of the most important metrics when it comes to performance.
The numbers shown here are best-run results for all frameworks, except for Mithril’s case, for which I’m taking the worst-run result. The numbers aren’t statistically rigorous (e.g. I didn’t bother to calculate standard deviation), but they should be enough to give a rough idea of what is faster than what.
Generally speaking, these tests are making a deliberate effort to be biased in favor of other frameworks: for example, I don’t load “optional-but-usually-used-in-real-life” things like the router module for Angular, or Marionette in Backbone’s case, and I load the entirety of Mithril. In addition, this test deliberately avoids triggering requestAnimationFrame
-based performance optimizations for Mithril, since this optimization does not exist in many frameworks and severely skews numbers in Mithril’s favor in CPU-intensive situations like parallax sites. I’m also NOT using the Mithril template compiler, which would also skew the benchmark in Mithril’s favor.
To run the execution time tests below, click on their respective links, run the profiler from your desired browser’s developer tools and measure the running time of a page refresh (lower is better).
Rendering
Mithril | 9.44ms (uncompiled) |
jQuery | 40.27ms |
Backbone | 23.05ms |
Angular | 118.63ms |
React | 79.65ms |
Feel free to implement versions of the tests above in other frameworks, if you wish. The code is very simple.
TodoMVC Benchmark
There’s a TodoMVC benchmark with a variety of popular and obscure frameworks here:
http://matt-esch.github.io/mercury-perf/
The benchmark consists of creating 100 todos, marking them as completed, and then deleting them. It aims to give an idea of how frameworks perform under real-world-ish conditions running idiomatic code (as opposed to micro-benchmarks, which tend to take advantage of obscure tricks and aggressive optimizations that sacrifice maintainability for extra speed).