Investigating Surface RT performance: Counting primes in C# and JavaScript

How is the performance of Surface RT? Tolerable but rather slow would be my quick summary. Surface RT has a quad-core NVIDIA Tegra 3 chipset.

In order to investigate further, I built a simple app to count primes, using essentially the code here. I ran the code both in JavaScript and in C#. This is a single ad-hoc and naive test that only covers one aspect of performance, but I have still found it an interesting indicator. I then ran the app both on my Intel Core i5 Samsung Slate and on Surface RT (yes it was interesting figuring out how to debug on Surface RT in a hotel room).

Here are the results:

On Intel Core i5:

  • Count primes up to 1,000,000: 1.05 secs (in browser)
  • Count primes up to 1,000,000: 0.88 secs (in embedded webview)
  • Count primes up to 1,000,000: 0.32 secs (C#)
  • Count primes up to 10,000,000: 6.31 secs (C#)

On Surface RT:

  • Count primes up to 1,000,000: 3.49 secs (in browser) Slower by 332%
  • Count primes up to 1,000,000: 3.53 secs (in embedded webview) Slower by 401%
  • Count primes up to 1,000,000: 1.81 secs (C#) Slower by 565%
  • Count primes up to 10,000,000: 49.03 secs (C#) Slower by 777%

The Core i5 is running at 1.6 Ghz. Surface RT has an NVidia Tegra 3 1.3 Ghz chipset.

You could count primes more quickly in both cases by using parallel processing; this is a single-threaded test.

What is notable here?

  • First, Surface RT is slower than I would expect and I hope Microsoft improves performance with future updates.
  • Second, C# is substantially faster than JavaScript in this test, around twice as fast, which makes me question the advice I have heard from some spokespersons that HTML and JavaScript is the preferred approach for apps.
  • Third, the factor by which C# is slower is greater than the factor by which JavaScript is slower. This surprised me; I had expected the reverse for some reason.

Of course, other performance tests will yield different results. When I tried the Sunspider JavaScript test Surface RT was about 5 times slower.

One piece of good news: there was little difference between performance in the embedded or non-embedded browser.

Update: I also tried this test in C++. There was barely any difference. The Core i5 counted primes up to 10,000,000 in 6 seconds. The Surface RT performed the same feat in 46 seconds.

Update 2: A Google Nexus 7, which also has a Tegra 3 chipset, can only manage 76 seconds for the JavaScript test (primes up to 10,000,000).