Job opening at While True: Testing engineer/developer August 18, 2009 No Comments

We need your help with automatic testing and development of MagCloud, a quickly rising cloud publishing service. Experience with latest happenings in .NET, C# and web development world are a big plus. You’ll be working in Stegne, Ljubljana, SI. Send examples of your work (code, links, references) and a CV to jobs at whiletrue dot com.

NT konferenca 2009: Continuous integration May 26, 2009 No Comments

Demo source code (6.17MB) from the talk “Continuous integration: good, bad and the ugly” given at the NT konferenca 2009 in Portorož, Slovenia. Check the included Readme file for instructions.

ASP.NET MVC Performance April 17, 2009 18 Comments

A closer look at the recently released ASP.NET MVC 1.0 preffered web development stack and some of its performance implications. All of the displayed techniques are in use in production at MagCloud.

The talk was first given in Slovene on 15.4.2009 at a local Microsoft developers user group, SLODUG.

Additional notes:

We cannot assume that only implementing database caching will lead to a significant performance gain before optimizing any other aspects of page’s rendering. Here’s a few more metrics for the DUGG application:

  • First run, as in the slides, no optimizations whatsoever: 5.9 requests / second
  • Added: Compiled SQL-LINQ queries: 6.88 requests / second
  • Added: Fully cached SQL-LINQ queries: 7.43 requests / second/
  • Removed: expression links, replaced with route and actions links. Also fixed path to partials with the full path: 112 requests/second

That still leaves room for the treble performance improvement with URL caching and views that render enumerations.

It’s one of the general rules of optimizing software that speedups in one part of the application will have a lot of consequences elsewhere which you can’t really predict. Test, measure, profile, optimize a single hotspot, repeat!

Errata (23.4.2009)

Thanks to Simone Chiaretta’s analysis of my results, he’s nailed it that I forgot to disable the debug mode for benchmarks (oops!). This disables ASP.NET MVC’s internal cache for paths to views, rendering my part of optimization notes to replace paths to views with full paths irrelevant. I’ve re-run all of the benchmarks, removed two slides and added an errata to the end of the slides.

It would be nice if I can be proven wrong on other points as well. :)

Marking variables in VS.NET Debugger July 20, 2007 No Comments

Technorati Tags: ,

Even after using Visual Studio for years (previous versions at least), you can always find hidden features.

If you are debugging and have watch window open, you can click on “Make Object ID”. This will create ID for specific object or its member. You will get id’s such as 1#, 2# etc.

Click on

From now on, you can use

1#.SomeMember();

even when this variable is not in scope. Quite useful for multithreaded debugging or for debugging code where you want to track specific objects through many layers.

object id's

Simple programming language performance benchmark(C# vs. Java vs. C++ vs. Ruby) May 8, 2006 1 Comment

After writting last entry on installation of .NET and Java runtimes I did a bit of searching. I noticed that one of very popular contest is .NET versus Java or C/C++ versus Java or C/C++ versus .NET (ok, I haven’t actually seen the last one in the wild, but I am sure it exists).

I have worked with all languages mentioned above. Assuming competent programmers, C/C++ with good compiler wins. Java and C# are usually about the same. I recently participated in one of the contest of topcoder.com. This confirms my statement. Also, keep in mind that coders in this contest are quite good and that Intel optimizing compiler is used, which supports SIMD (Single Instruction Multiple Data) instructions and is supposed to do vectorisation and other cool stuff.

Now, the funny part. For the many (most?) applications language (and platform) speed is not important. Even if one platform is 2x faster then the other, that is relatively unimportant. Of course, there are exceptions. You want games to be fast, image and video processing should be fast. But once application response time for any input is below, say, 0.1 s, there is rarely reason to optimize it.

I have been doing quite a lot of Ruby (on Rails and pure Ruby). Now, Ruby is slow. But writting code is fast (Rails is also awesome web framework). You might not want to base your Google killer search engine on Ruby but for many applications, Ruby is fast enough.

Now, I will stop talking and actually do some testing. Below is source code for very simple performance test.
The code itself has no significance. I only wanted two loops and some operations. Timing was done from batch files.
Timer started before the program was started and ended after program exited. So start-up times WERE included in the time.

C#


using System;
class Perf
{
public static void Main()
{
long val = 0;
for (int x = 0; x < 10000; x++)
{
for (int y = 0; y < 100000; y++) val += y + x;
}
Console.WriteLine("Val = {0}", val);
}
}

Java


class perf
{
public static void main(String[] args)
{
long val = 0;
for (int x = 0; x < 10000; x++)
{
for (int y = 0; y < 100000; y++) val += y + x;
}
System.out.println("Val = " + val);
}
}

C++


#include
using namespace std;
int main()
{
long long val = 0;
for (int x = 0; x < 10000; x++)
{
for (int y = 0; y < 100000; y++) val += (y + x);
}
cout << "Val =" << val << endl;
return 0;
}

Ruby

val = 0
0.upto(10000) do |x|
0.upto(100000) do |y|
val += x + y
end
end
puts "Val = #{val}"

This was run on 1.7 Ghz IBM Thinkpad with 1.5Gb of RAM and Windows XP Professional SP2 (not that RAM is important here, maybe in some other test?). Each test was run a couple of times and best time was recorded.

Java 1.5 (command line: java perf -server)
6.84 seconds

C# 2.0, without ngen.exe (code with ngen.exe was .3 seconds slower, go figure ):
4.02 seconds

C++ (compiled with cl cpp_perf.cpp /Og /Ox)

2.97 seconds

Ruby (it was so slow, I ran it for 1% of cases and extrapolated)
3861 seconds (yes, there is no dot in there. It is more that 1 hour).

Now, what does that tell us? First, you should not use Ruby (or any other scripting language) for numberic processing. Really, they are not intended for that.
Now, if you are Java guy and feel that C# "won" this round, you are mistaken. If 50% speed increase in numberical processing is significant for you, neither C# nor Java are right for you. C++ is the way to go. I used MS Visual C++ (from MS.NET 2005). If I used intel compiler, things might be different.

The moral of the story is: C++ for performance critical things (e.g where number chrunching performance factor 2x is an issue. It happens less than you would think). C#/Java have "good enough" performance for most tasks. Pure numerical performance should not be a factor in deciding which language to take (for c# vs. java).
Ruby shows the weakest point of scripting languages - pure speed. But once you start being limited by other things (databases, web services, file system - pure speed becomes less and less of an issue).

And keep in mind, even handcrafted assembly code bubble-sort code written for exact hardware will lose agains quicksort algorithm (even if written in Ruby...). At least for large enough number of elements.