Often, a developer's goal is to create software that runs on many different operating systems, while giving users the same experience no matter which operating system they happen to be using. Virtual machine technology lets developers run multiple operating systems each installed in a VM, which should save them time and money -- if the VM performance doesn't suffer.

To determine whether it's viable to run a VM as a testing/developing environment for software development, I ran a battery of performance tests, all using Java running on various configurations of Ubuntu Linux and Windows. This allowed comparisons between the host control PCs and the virtual setups. I created tests to compare three factors: processing speed, speed of the network interface cards, and input/output speeds of hard drives, all comparing performance on the various configurations. The source for all of the test programs is available for download here.

The processor speeds and RAM allotments of the host PC and the guest PC were:

The host PC sees a 1.73-GHz processor and 2.00 GB of RAM.

The guest PC sees a 1.73 GHZ processor and 512 MB of RAM.

The difference in the RAM is because the guest gets allocated 512 MB (or as specified) of the 2.00 GB of the host.

There were six total configurations on which I conducted tests. I ran two controls using only the host:

One test on Ubuntu Linux.

One test on Microsoft's Windows XP.

The other tests were run on combinations of hosts and guests:

Ubuntu Linux (guest) on Ubuntu Linux.

Windows (guest) on Ubuntu Linux.

Windows (guest) on Windows

Ubuntu Linux (guest) on Windows.

Each test was run 100 times and the results were averaged to get more accurate measurements. All of the tests were run on clean installs of the operating systems with only the default settings to get the most unaffected and comparable results.

The first test was to determine the comparative processing speed of the configurations. To test the processing speed, I wrote a test program that tabulates the time it takes to create 500,000 Java objects (Figure 1).

[Click image to view at full size]

The results show a minor decrease in performance compared to the controls when the host operating system is the same as the guest operating system. The most surprising result is the difference between running Ubuntu-on-Windows and running Windows-on-Ubuntu. Windows-on-Ubuntu took more than twice the time in creating the objects compared to the control, while Ubuntu-on-Windows was actually faster than Windows-on-Windows. Overall, the results show that there are no major differences between the guest and the host, Windows-on-Ubuntu notwithstanding. I suspect that the large differences here are a result of the way the abstraction layer executes the Windows code when Ubuntu is the host.

The next test was to determine the comparative speed of the NICs on the various configurations. To do this, I wrote a second test program that executes a SQL query through the Java Database Connectivity (JDBC) API (Figure 2).

[Click image to view at full size]

The SQL query result set included 99,900 rows. The results here show a distinct speed difference when using Ubuntu as the host system, compared to Windows as the host. I suspect that the reason is that drivers for devices such as NICs are specifically written by manufacturers for Windows, while drivers in Linux distributions (such as Ubuntu) are written by the open-source community, which may lead to slight differences in implementations. There is almost no speed difference between the Windows control and the guests on Windows. On the Ubuntu side, there is a little more variation, with the surprise that Ubuntu on Ubuntu is the slowest (although not exceedingly far behind the control). Again, I attribute this to the drivers for Ubuntu being written by the open-source community instead of NIC manufacturer.

The third test program I wrote determines the comparative input/output speeds of hard drives on the various configurations. To do this, the program outputs a large text file, which the program reads back in. The speeds of each operation are then calculated (Figure 3).

[Click image to view at full size]

The key thing to remember is that the VM's so-called "hard drive" is actually just a file on the host's hard drive.

These results show little variation when Windows is the host, but much more variation when Ubuntu is the host. With Windows and Ubuntu as the controls, their results are similar, as are the two guest configurations on Windows. The main surprise in this test is that Windows-on-Ubuntu was almost twice as slow on both the input and the output side of things.

A final test program took in all of the previous tests for an overall perspective on performance, using a program that queries a SQL database and outputs the result set to a file. It then reads the file back in and creates objects populated with what's in the file (Figure 4).

[Click image to view at full size]

The tests show similar results across the board, with the exception of Windows-on-Ubuntu, which underperformed the others consistently. The tests show fairly conclusively that, except for the Windows-on-Ubuntu case, a VM is just as usable as a physical PC for software development. While there's a slight degradation in performance in many cases, the decrease is minor overall and likely worth the efficiency gains from having any operating system readily available.