Method
This is a very rough, and thus not very rigourous evaluation. I performed all tests on a PowerBook G4 1GHz running Mac OS X 10.5 under the same operating conditions (ie. on the train home from work). The versions used:- Subversion 1.4.4
- Mercurial 0.9.5 with Python 2.5
Results
All times as reported by the bash time command, taking the real time value (ie. elapsed system time):
| Operation | Mercurial | Subversion | Speedup |
|---|---|---|---|
| Create Repository | 0.346s | 0.279s | svn 1.2X |
| Import source tree | 12.241s | 1m3.781s | hg 5.2X |
| Checkout | 19.808s | 1m1.356s | hg 3.1X |
| Status (1 mod) | 0.631s | 0.265s | svn 2.4X |
| Diff (1 mod) | 0.778s | 0.212s | svn 3.7X |
| Diff (2 mods) | 0.784s | 0.331s | svn 2.4X |
| Commit (2 mods) | 1.164s | 3.442s | hg 3.0X |
| Add file | 0.544s | 0.121s | svn 4.5X |
| Commit | 0.922s | 2.920s | hg 3.2X |
| Total | 37.218s | 132.707s | hg 3.6X |
Conclusions
A simple count of which is faster for each operation shows both scored 5/10, so in that sense they are evenly matched. But in the cases where Subversion was faster, the times were still well under 1sec, so the difference is far less noticeable. It is clear from the above that for many expensive operations, Mercurial is significantly faster than Subversion, even for large I/O operations such as commits and importing. Given Mercurial is written in Python (apart from one small module IIRC), and Subversion is compiled C, this is all the more impressive. Looking at the overall total times for the test workload, Mercurial comes out at 3.6 times faster than Subversion. If you are spending a lot of time with your VC system, this can make a huge difference to your workday productivity.
Clearly the build-in diff engine in Subversion gives it a major advantage in diffs, a very important and common operation. Mercurial is still competitive, and in real-world tests seem to scale well. Having tested it at work with an even larger source tree (the Boost++ library), Mercurial actually seemed to be faster than Subversion for status operations in particular (around a second versus several seconds).
It should be noted that since running Subversion from a local repository like this is the exception rather than the norm for most projects, the performance advantage it has thanks to its fast diff engine evaporates against network latency. Thus using a distributed VCS such as Mercurial can be a great productivity boost, as you only pay for the network when you need to branch or merge between developers, a far less common operation.
This comparison has reinforced my positive impressions of Mercurial, and I hope it serves to bolster peoples' confidence in its ability to scale and perform. It has all the features of Subversion, plus many more groovy features like patch queues (which I may blog about one day). Since Mercurial is less well known, I hope more people will give it a try.


Leave a comment