Tag Archives: performance

C# vs C++ and .NET vs Mono vs Compact Framework performance tests

A detailed benchmark posted on codeproject investigates the performance of basic operations including string handling, hash tables, math generics, simple arithmetic, sorting, file scanning and (for C#) platform invoke of native code. These are the conclusions:

  • There is only a small performance penalty for C# on the desktop versus C++.
  • Mono is generally slower than Microsoft .NET but still acceptable, and all the benchmarks ran without modification.
  • The Compact Framework, an implementation of .NET for mobile devices, performs poorly.

My observations: this matches my own experiments. Why then do some .NET applications still perform badly? When Evernote switched its application from .NET to native code it got much better performance.

The main reason is a couple of issues that this kind of benchmark hides. One is the GUI layer, which involves a ton of platform invoke code under the covers. Another is the large size of .NET applications because of the runtime and library overhead; a lot more stuff gets loaded into memory.

One thing to like about Silverlight is that it is truly optimized for client programming and load time tends to be faster than for a desktop .NET application.

Note that for mobile these benchmarks suggest that C++ still has a big advantage. It would be interesting to see them applied to Silverlight apps on Windows Phone 7. As I understand it, the Silverlight .NET runtime in Windows Phone 7 shares code with the Compact Framework on Windows Mobile, so it is possible that the poor results for the Compact Framework would also apply to Silverlight on Windows Phone 7. Unfortunately developers do not have the option for C++ on Windows Phone 7.

Fixing slow access to SharePoint mapped drives in Windows 7

I’ve heard recently from a couple of people who found that accessing SharePoint folders via mapped drives in Windows Explorer had suddenly become very slow – even taking several minutes to open a folder. This is in Windows 7, but the same might (or might not) apply to other versions of Windows.

SharePoint folders in Windows Explorer use WebDAV (Web-based Distributed Authoring and Versioning) under the hood, so although it looks like just another shared drive it is actually using HTTP calls to list the files. It is useful if you are out and about, because you can get at documents on your internal network over the internet, using SSL to secure the connection.

The fix that has worked in both cases is a mysterious one. You open Internet Explorer (even if you use a different browser), go to Tools – Internet Options – Connections, click LAN settings, and uncheck Automatically detect settings.

image

I am not sure why this works but presumably with this option checked there is some sort of useless auto-detection going on which times out and then repeats.

No promises; but making this change can dramatically improve performance.

Measuring start-up time for .NET, Java, C++

A comment here points me to this comparison by Decebal Mihailescu of start-up times for processes on Windows using different runtimes: .NET in several versions, Java 1.6, Mono 2.6.4, and Visual C++ 2010 (native code).

image

It is notable that native code is much faster than the runtimes, and that .NET is ahead of Java – to be expected, perhaps, since Windows is its native environment.

The test application is tiny and when we are talking about a time of less than a tenth of a second, users are unlikely to care much. I would like to see tests based on a larger application; on the other hand it becomes increasingly difficult to make a fair comparison.

It’s a shame Embarcadero Delphi was not included, though I’d expect similar figures to those for Visual C++.

Start-up time is critical to perceived performance. One reason I use an ancient version of Paint Shop Pro for simple image manipulation is that I can double-click an image and be editing it instantly, whereas alternatives like Adobe PhotoShop or the free paint.net make me wait. Unless I need the extra features these provide, I stick with fast and simple.

Silverlight 4 vs Silverlight 3: a little bit faster?

Microsoft’s Scott Guthrie spoke of “twice as fast performance” in the newly-released Silverlight 4, thanks to a new just-in-time compiler.

Performance is a hard thing to nail down. Maybe he meant that compilation is twice as fast? I’m not sure; but I tried a couple of quick tests.

First, I looked at my Primes test. Version 3 running in Windows Vista took around 0.40 seconds (the exact figure varies on each run, thanks to background processes or other factors). I then upgraded to version 4.0. No significant difference, on average over several runs. I used Vista because I’d already upgraded my Windows 7 install.

Next I tried Bubblemark. I maxed it out at 128 bubbles. On Vista with Silverlight 3 I got about 240 fps; on the same machine with Silverlight 4 about 260fps; about 8%.

image

Next I tried on an Apple Mac. My Mac Mini is less powerful, though not that bad, an Intel 1.83 Ghz Core Duo. On the Prime test I got 0.54 secs before, and 0.50 secs after the upgrade to 4.0, about 7.5% improvement. On Bubblemark, it was only 24 fps before and after.

I guess the vast difference in graphics performance is also interesting. It is not just Mac vs Windows; the Nvidia GeForce 6800 on the PC is more powerful than whatever is in the Mac Mini.

If anyone can tell me in what respect version 4.0 is twice as fast, I’d be grateful.

Update: prompted by the comment from David Heffernan below, I also tried the Encog Silverlight Benchmark. I used an older core duo laptop, since I am running out of machines to upgrade. I ran the test twice before upgrading, and twice after. Lower is better:

Silverlight 3.0: 22.0

Silverlight 4.0: 12.7

That’s about 42% better, where “twice as fast” would be 50% better, much closer to Guthrie’s claim. I guess it depends what you measure.